rolfn / eso-pic

LaTeX package to add pic­ture com­mands (or back­grounds) to ev­ery page
Other
4 stars 1 forks source link

\TextUpperLeft faulty in memoir #5

Closed u-fischer closed 1 year ago

u-fischer commented 1 year ago

If one use in a oneside memoir document the asymetric margins, eso-pic calculates a faulty position for the left side of the text on even pages:

\documentclass[oneside]{memoir} %oneside!
\setlrmarginsandblock{0.5in}{2in}{*}
\checkandfixthelayout
\usepackage{showframe,lipsum,color} %showframe uses eso-pic
\AddToShipoutPictureFG{\AtTextUpperLeft{\textcolor{red}{XXXX}}}
\begin{document}

\lipsum[1-10] 

\newpage 
Suggested fix:
\makeatletter
\renewcommand\AtTextUpperLeft[1]{%
    \begingroup
      \if@twoside  %<-- added
      \ifodd\c@page
        \ESO@tempdima=\spinemargin
      \else
        \ESO@tempdima=\paperwidth
        \advance\ESO@tempdima-\textwidth
        \advance\ESO@tempdima-\spinemargin
      \fi                              
      \else                    %<---
       \ESO@tempdima=\spinemargin %<----
      \fi %<----
      \ESO@tempdimb=-\uppermargin
      \AtPageUpperLeft{%
        \put(\ESO@tempdima,\ESO@tempdimb){#1}%
      }%
    \endgroup
  }

\lipsum[1-10] 

\end{document}

image

rolfn commented 1 year ago

Thank you for the bug report and the fix suggestion. The new version 3.0c corrects the error and will be available on CTAN shortly.