Page Layoutoverlapping of text and notes in each even page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
abclatex
Posts: 17
Joined: Wed Nov 28, 2012 10:09 pm

overlapping of text and notes in each even page

Post by abclatex »

Hi all,

The below codes (which help to put the footnotes at the bottom of margin) can work well in oneside article, but not in twoside book. There would be overlapping of text and footnotes in each even page because the footnotes appear on the right side instead of at the margin of each even page.

I read them word by word, but cannot figure out how to fix it. Thanks for any suggestions.

Code: Select all

\documentclass[a4paper,twoside,symmetric,nols]{tufte-book}
\usepackage[american]{babel}
\usepackage{blindtext}


%% footnote format
\usepackage{forarray,etoolbox,xifthen,,graphicx,picture,calc,atbegshi,lipsum,color}

\newlength{\vincrement}

\newlength{\fmvorigin}
\newlength{\fmhorigin}
\newlength{\fmvoffset}
\newlength{\nextfmvoffset}
\newlength{\fmvskip}

\setlength{\fmvorigin}{-1in-\voffset-\topmargin-\headheight-\headsep-\textheight}
\makeatletter
    \ifthenelse{\isundefined{\Gm@lmargin}}%
    {\setlength{\fmhorigin}{1in+\hoffset+\oddsidemargin+\textwidth+\marginparsep}}%
    {\setlength{\fmhorigin}{\Gm@lmargin+\textwidth+\marginparsep}}
\makeatother
\setlength{\fmvoffset}{0pt}
\setlength{\fmvskip}{3ex}

\newlength{\tmvorigin}
\newlength{\tmhorigin}
\newlength{\tmvoffset}
\newlength{\nexttmvoffset}
\newlength{\tmvskip}
\newlength{\maxtmnheight}

\setlength{\tmvorigin}{-1in-\voffset-\topmargin-\headheight-\headsep-\baselineskip}
\setlength{\tmhorigin}{\fmhorigin}
\setlength{\tmvoffset}{0pt}
\setlength{\tmvskip}{6ex}

\newcounter{fmn}
\newcounter{tmn}

\newboolean{marginisfull}

\newcommand{\fmnbuffer}{}
\newcommand{\currentfmnqueue}{}
\newcommand{\nextfmnqueue}{}

\newcommand{\tmnbuffer}{}
\newcommand{\currenttmnqueue}{}
\newcommand{\nexttmnqueue}{}

\newcommand{\append}[2]{%
    \ifdefempty{#1}{}{\eappto{#1}{,}}%
    \eappto{#1}{#2}%
    }

\newcommand{\prepend}[2]{%
    \ifdefempty{#1}{}{\epreto{#1}{,}}%
    \epreto{#1}{#2}%
    }

\newcommand{\footmarginnote}[1]{%
    \addtocounter{fmn}{1}%
    \expandafter\newsavebox\csname fmnbox\roman{fmn}\endcsname%
    \expandafter\savebox\csname fmnbox\roman{fmn}\endcsname{\parbox[b]{\marginparwidth}{#1}}%
    \append{\currentfmnqueue}{\roman{fmn}}%
    }

\newcommand{\topmarginnote}[1]{%
    \addtocounter{tmn}{1}%
    \expandafter\newsavebox\csname tmnbox\roman{tmn}\endcsname%
    \expandafter\savebox\csname tmnbox\roman{tmn}\endcsname{\parbox[t]{\marginparwidth}{\vskip-0.75\baselineskip#1}}%
    \append{\currenttmnqueue}{\roman{tmn}}%
    }

\newcommand{\printfmn}{%
    \setlength{\fmvoffset}{0pt}%
    \setboolean{marginisfull}{false}%
    \ifdefempty{\currentfmnqueue}{}{%
        \gdef\nextfmnqueue{}%
        \gdef\fmnbuffer{}%
        \ForEachX{,}{%
            \ifthenelse{\boolean{marginisfull}}%
                {\append{\nextfmnqueue}{\thislevelitem}}%
                {%
                \setlength{\vincrement}%
                    {\fmvskip+\expandafter\ht\csname fmnbox\thislevelitem\endcsname+\dp\csname fmnbox\thislevelitem\endcsname}%
                \setlength{\nextfmvoffset}{\fmvoffset+\vincrement}%
                \ifthenelse{\lengthtest{\nextfmvoffset>\textheight}}{%
                    \setboolean{marginisfull}{true}%
                    \append{\nextfmnqueue}{\thislevelitem}%
                    }{%
                    \prepend{\fmnbuffer}{\thislevelitem}%
                    \addtolength{\fmvoffset}{\vincrement}%
                    }%
                }%
            }%
            {\currentfmnqueue}%
        \setlength{\fmvoffset}{0pt}%
        \ForEachX{,}{%
            \put(\fmhorigin,\fmvorigin+\fmvoffset){\expandafter\usebox\csname fmnbox\thislevelitem\endcsname}%
            \setlength{\vincrement}%
                {\fmvskip+\expandafter\ht\csname fmnbox\thislevelitem\endcsname+\dp\csname fmnbox\thislevelitem\endcsname}%
            \addtolength{\fmvoffset}{\vincrement}%
            }%
            {\fmnbuffer}%
        \global\let\currentfmnqueue\nextfmnqueue%
        }%
    }

\newcommand{\printtmn}{%
    \setlength{\maxtmnheight}{\textheight-\fmvoffset}%
    \setlength{\tmvoffset}{0pt}%
    \setboolean{marginisfull}{false}%
    \ifdefempty{\currenttmnqueue}{}{%
        \gdef\nexttmnqueue{}%
        \gdef\tmnbuffer{}%
        \ForEachX{,}{%
            \ifthenelse{\boolean{marginisfull}}%
                {\append{\nexttmnqueue}{\thislevelitem}}%
                {%
                \setlength{\vincrement}%
                    {\tmvskip+\expandafter\ht\csname tmnbox\thislevelitem\endcsname+\dp\csname tmnbox\thislevelitem\endcsname}%
                \setlength{\nexttmvoffset}{\tmvoffset+\vincrement}%
                \ifthenelse{\lengthtest{\nexttmvoffset>\maxtmnheight}}{%
                    \setboolean{marginisfull}{true}%
                    \append{\nexttmnqueue}{\thislevelitem}%
                    }{%
                    \append{\tmnbuffer}{\thislevelitem}%
                    \addtolength{\tmvoffset}{\vincrement}%
                    }%
                }%
            }%
            {\currenttmnqueue}%
        \setlength{\tmvoffset}{0pt}%
        \ifdefempty{\tmnbuffer}{}{%
            \ForEachX{,}{%
                \put(\tmhorigin,\tmvorigin-\tmvoffset){\expandafter\usebox\csname tmnbox\thislevelitem\endcsname}%
                \setlength{\vincrement}%
                    {\tmvskip+\expandafter\ht\csname tmnbox\thislevelitem\endcsname+\dp\csname tmnbox\thislevelitem\endcsname}%
                \addtolength{\tmvoffset}{\vincrement}%
                }%
                {\tmnbuffer}%
            }%
        \global\let\currenttmnqueue\nexttmnqueue%
        }%
    }

\AtBeginShipout{\AtBeginShipoutUpperLeft{\printfmn\printtmn}}

\makeatletter
\renewcommand{\footnote}[1]{\footnotemark\footmarginnote{\textsuperscript{\@thefnmark}\,#1}}
\makeatother

\begin{document}
Text\footnote{This is the first footnote.}
\blindtext
\blindtext

Text\footnote{This is the second and somewhat longer footnote.}
\blindtext
\blindtext

Text\footnote{This is the third footnote.}
\blindtext
\blindtext

Text\footnote{This is the fourth footnote.}
\blindtext
\blindtext

Text\footnote{This is the fifth footnote.}
\blindtext
\blindtext

Text\footnote{This is the sixth footnote.}
\blindtext

\end{document} 
The overlapping problem:
problem.JPG
problem.JPG (39.57 KiB) Viewed 3480 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

overlapping of text and notes in each even page

Post by cgnieder »

I don't know know where you have the code from but it does not seem to be your own. If it were you knew that it explicitly places the notes to the right and does make any decisions depending on odd and even pages. I only took a quick glance through so I'm not sure where to patch the code right now. Unfortunately it isn't documented at all!

Maybe you should ask the author of the code if he can provide a patch for you?

Regards
site moderator & package author
Post Reply