Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using eledmac to typeset a doc with two columns in memoir. The first line number at the top of the right column continues to be placed to the left of the column, as it was with the left column, rather than in the margin to the right. The same is true for the left column beginning on the second page (its first line number continues from the right column on the preceding page to be placed to the right of the column). I thought of using the \multicol package, but I need to use eledmac for the line numbering / critical apparatus. I also tried eledmac's \linenummargin command, but without success. Sure I must be missing an easy workaround. Appending a mwe:

\documentclass[letterpaper,12pt,twocolumn,landscape]{memoir}
\usepackage{polyglossia}
\usepackage[parapparatus]{eledmac}
\usepackage{lipsum}
\usepackage{verse}
\setlrmarginsandblock{.75in}{.75in}{1} 
\setulmarginsandblock{.75in}{.75in}{1} 
\checkandfixthelayout 
\setcolsepandrule{28pt}{0pt}
\setcounter{firstlinenum}{1}
\setcounter{linenumincrement}{2}
\lineation{page}
\linenummargin{right}

\begin{document}
\chapter*{Hello World}
\beginnumbering
\pstart
\lipsum
\pend
\endnumbering
\end{document}

and images of the much improved result thanks to David Carlisle's helpful responses (now it is just the top # on most pages that is off): lipsum ex. my actual doc

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

The original version is at the end, this version saves the page as well as line number in the position information sp it can cope with the line number being re-set

enter image description here

\documentclass[letterpaper,12pt,twocolumn,landscape]{memoir}
\usepackage{polyglossia}
\usepackage[parapparatus]{eledmac}
\usepackage{lipsum}
\usepackage{verse}
\setcounter{firstlinenum}{1}
\setcounter{linenumincrement}{2}
\lineation{page}
\linenummargin{right}



\makeatletter


\def\eldefkey{\romannumeral\line@num @\romannumeral\c@page}

\let\saved@affixline@num\affixline@num
\def\affixline@num{{%
\pdfsavepos
\edef\tmp{\write\@auxout{%
\gdef\string\eldef \romannumeral\line@num @\noexpand\romannumeral\c@page
{\noexpand\the\pdflastxpos}}}%
\tmp
\expandafter\ifx\csname eldef\eldefkey\endcsname\relax
\else
 \ifnum \csname eldef\eldefkey\endcsname=3818782 % 3818782
          \@firstcolumntrue
 \else \ifnum \csname eldef\eldefkey\endcsname=25445662 % 19514654
     \@firstcolumnfalse
 \else \ifnum \csname eldef\eldefkey\endcsname=5653790 % 5653790
          \@firstcolumntrue
 \else \ifnum \csname eldef\eldefkey\endcsname=27280670 % 21349662
        \@firstcolumnfalse
\else
  \showthe\line@num
 \fi\fi\fi\fi
\fi
% force first number to first column
\ifnum\line@num=1
\@firstcolumntrue
\fi
\saved@affixline@num}}


\renewcommand*{\affixpstart@num}{%
    \ifsidepstartnum
        \if@twocolumn
            \if@firstcolumn
                  \gdef\l@dld@ta{\llap{QQQQ{\leftpstartnum}}}%
            \else
                  \gdef\l@drd@ta{\rlap{PPPP{\rightpstartnum}}}%
            \fi
        \else
             \@l@dtempcntb=\line@margin
            \ifnum\@l@dtempcntb>\@ne
                  \advance\@l@dtempcntb \page@num
            \fi
            \ifodd\@l@dtempcntb
                  \gdef\l@drd@ta{\rlap{XXXXX{\rightpstartnum}}}%
            \else
                  \gdef\l@dld@ta{\llap{YYYYY{\leftpstartnum}}}%
            \fi
        \fi
    \fi

}

\makeatother

\begin{document}
\chapter*{Hello World}
\beginnumbering
\pstart
\lipsum
\pend
\endnumbering
\end{document}

I didn't have the fonts so this is tested with the standard font setup, but appears to work. Not a complete fix but a manual work-around for when things go wrong, the code added in the preamble forces the line number 30 to switch sides.

\documentclass[letterpaper,12pt,twocolumn]{memoir}
\usepackage{polyglossia}
\usepackage[parapparatus]{eledmac}
\usepackage{lipsum}

%\setmainfont{Linux Libertine O}
\linenummargin{left}
\makeatletter

\let\saved@affixline@num\affixline@num
\def\affixline@num{{%
\pdfsavepos
\edef\tmp{\write\@auxout{%
\gdef\string\eldef\romannumeral\line@num{\noexpand\the\pdflastxpos}}}%
\tmp
\expandafter\ifx\csname eldef\romannumeral\line@num\endcsname\relax
\else
 \ifnum \csname eldef\romannumeral\line@num\endcsname=3818782
          \@firstcolumntrue
 \else \ifnum \csname eldef\romannumeral\line@num\endcsname=19514654
     \@firstcolumnfalse
 \else \ifnum \csname eldef\romannumeral\line@num\endcsname=5653790
          \@firstcolumntrue
 \else \ifnum \csname eldef\romannumeral\line@num\endcsname=21349662
        \@firstcolumnfalse
\else
  \showthe\line@num
 \fi\fi\fi\fi
\fi
\saved@affixline@num}}
\makeatother

\begin{document}
\chapter*{Hello World}
\beginnumbering
\pstart
\lipsum
\pend
\endnumbering
\end{document}
share|improve this answer
    
Thanks much for the idea. I'm sorry; I neglected to mention that my document is quite long, which makes implementing your manual fix less desirable. If it comes to that, it comes to that, but I'm hoping for a global fix. Thanks again. –  camatkara Dec 17 '12 at 14:53
    
automatic version added, will get it right on the second pass. the four numbers are the x-position of the first and second column on odd and even pages. they are correct for the document as posted if you change page size just copy them from the aux file. Any unexpected position will stop at the \showthe line –  David Carlisle Dec 17 '12 at 16:25
    
Thanks, that works for the mwe! I didn't realize any solution given would conflict with other parameters I've set, but this one seems to. Is it difficult to tweak this solution to deal with "landscape" in the doc class option and layout parameters of the following? \setlrmarginsandblock{.75in}{.75in}{1} \setulmarginsandblock{.75in}{.75in}{1} \checkandfixthelayout \setcolsepandrule{28pt}{0pt} –  camatkara Dec 17 '12 at 18:39
    
Hasty in my last reply...copying the .aux numbers now. Will report back shortly. –  camatkara Dec 17 '12 at 18:46
    
Hey, it basically works! But there are some factors that are throwing it off. I'm sorry not to have included them in the mwe, but I didn't know they would be relevant. I'm using \lineation{page}, which with this setup throws the numbering to the wrong side occasionally. Also, I'm using \setcounter{firstlinenum}{1} and \setcounter{linenumincrement}{2}, which with this setup really throws the numbering back and forth. Finally, the "verse" with (\altverse) package seems to be throwing things off as well. I'll update the mwe now... –  camatkara Dec 17 '12 at 19:22
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.