maieul / ledmac

package reledmac for latex
http://www.ctan.org/tex-archive/macros/latex/contrib/reledmac
54 stars 28 forks source link

Option for declaring custom commands for inclusion in \sameword macros #668

Closed stenskjaer closed 7 years ago

stenskjaer commented 7 years ago

Should we add a command for to define an arbitrary list of macros which could be allowed in sameword. As @maieul says in the discussion in https://github.com/stenskjaer/samewords/issues/7:

But as it could be macro with one or more argument, the user should have to do it own \let command.

For example you should have to do

\apptocmd{\sameword@noexpands}{
\let\macro\relax
}
floriandk commented 7 years ago

Custom commands would be great!

As also discussed in the thread, I'd suggest to include at least some more of the most frequent commands as allowed by default:

stenskjaer commented 7 years ago

Are the index commands currently a problem? As I understand it, it should only be a problem with macros that change the font properties.

floriandk commented 7 years ago

That's a bit strange:

\documentclass{article}
\usepackage[series={A},nofamiliar,noeledsec,noledgroup]{reledmac}

\usepackage{makeidx}
\makeindex

\begin{document}

\beginnumbering
\pstart
Han var sonr 
\edtext{\sameword[1]{Hákonar\index{Håkon II} konungs}}%
  {\Afootnote{k\emph{on}gſ hakon\emph{ar} Sk}}%
, sons \sameword{Hákonar\index{Håkon I} konungs}
\pend
\endnumbering

\end{document}

will compile with pdflatexor lualatex -- but with the obvious problem, that \index isn't ignored completely and that the sameword-counter thus will not be set correctly.

But with xelatex it doesn't compile at all:

Writing index file indexsw.idx
(./indexsw.aux) ABD: EverySelectfont initializing macros Section 1 (./indexsw.1

./indexsw.1:5: Undefined control sequence.
\\  ->\let \reserved@e 
                       \relax \let \reserved@f \relax \@ifstar {\let \reserv...
l.5 ]

? 
Process aborted
maieul commented 7 years ago

the most complex point is the fact that \edindex can have an optional argument.

I will ask help to SE

maieul commented 7 years ago

please try issue668 branch.

It add swnoexpands command, which can be completed with \appto.

It contains newdefinition for \index, \edindex and language switching command. Cf. ecbdf3c0

stenskjaer commented 7 years ago

Okay. I just tested issue668 branch, and the indexing seems to work for me here (@floriandk, do you agree?).

I also tried creating a custom command with the following mwe:

\documentclass{article}
\usepackage[series={A},nofamiliar,noeledsec,noledgroup]{reledmac}
\usepackage{polyglossia}
\setmainlanguage{french}
\setotherlanguage{english}
\usepackage{makeidx}
\makeindex

\newcommand{\somemacro}[1]{}

\makeatletter
\appto{\swnoexpands}{%
  \let\somemacro\@firstofone%
}
\makeatother

\begin{document}
\beginnumbering
\pstart
Han var sonr \edtext{\sameword[1]{Hákonar\somemacro{Håkon II}\textenglish{sncf} konungs}}%
  {\Afootnote{k\emph{on}gſ hakon\emph{ar} Sk}}%
, sons \sameword{Hákonar\somemacro{Håkon I}\textenglish{sncf} konungs}
\pend
\endnumbering

\end{document}

When I do that, it does not compare the samewords correctly. I am probably doing something wrong, but can you tell me what it is?

maieul commented 7 years ago

\@firstofone mean you want to return the first argument.

So the result is as in your first \sameword you get

HákonarHåkon IIsncf konungs

and in the second one

HákonarHåkon Isncf konungs

What you want, in reality, is to get nothing in place of \somemacro.

So \let\somemacro\@gobble

to get in the two cases

Hákonarsncf konungs

Le 7 août 2017 à 14:48, Michael Stenskjær Christensen notifications@github.com a écrit :

Okay. I just tested issue668 branch, and the indexing seems to work for me here (@floriandk, do you agree?).

I also tried creating a custom command with the following mwe:

\documentclass {article}

\usepackage [series={A},nofamiliar,noeledsec,noledgroup]{reledmac}

\usepackage {polyglossia}

\setmainlanguage {french}

\setotherlanguage {english}

\usepackage {makeidx}

\makeindex

\newcommand{\somemacro }[1]{}

\makeatletter \appto{\swnoexpands}{%

\let\somemacro\@firstofone%

}

\makeatother

\begin {document}

\beginnumbering \pstart

Han var sonr \edtext{\sameword[1]{Hákonar\somemacro{Håkon II}\textenglish{sncf} konungs}}%

{ \Afootnote{k\emph{on}gſ hakon\emph{ar} Sk}}%

, sons \sameword{Hákonar\somemacro{Håkon I}\textenglish {sncf} konungs}

\pend \endnumbering

\end{document} When I do that, it does not compare the samewords correctly. I am probably doing something wrong, but can you tell me what it is?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

stenskjaer commented 7 years ago

Yes! That solves it. It is cool 👍 Should we add some description to the docs? Can I do anything? Proof-read, write a draft or something?

maieul commented 7 years ago

maybe writing a draft

stenskjaer commented 7 years ago

I have added a draft. It may need to be rewritten to remove inaccuracies or wrong commands. See https://github.com/maieul/ledmac/pull/670

maieul commented 7 years ago

I have completed the draf. In reality, the problem happens will all not fully expansable macro. I have also corrected some typo.

I will publish it on CTAN when my computer will be ok.

maieul commented 7 years ago

I fix this issue and merge the branch in the release branch.