使用一个输入文件和多个输入文件的行为差异

使用一个输入文件和多个输入文件的行为差异

我注意到加载单个文件时的行为有所不同

\input{letters/all_letters}

使用命令加载多个文件时

\newcommand*{\alphabetF}{%
  a,aa,b,c,d,e,ee,f,g,h,i,ii,j,k,l,m,
  n,o,oo,p,r,s1,s2, t,u,uu,v,w,x,y,yy,th,ae,oe}

\foreach \l in \alphabetF{
  \input{letters/\l.tex}}

不同之处在于拇指索引的行为。当字母开始翻页时,拇指索引从(字母的)最后一页消失,并出现在下一个字母的第一页上。如果字母从第二列开始,则行为是正确的。

在此处输入图片描述

% THUMB INDEXES
% new counter to hold the current number of the letter to determine the vertical position
\newcounter{letternum}
% newcounter for the sum of all letters to get the right height of a box
\newcounter{lettersum}
\setcounter{lettersum}{34}
% some margin settings
\newlength{\thumbtopmargin}
\setlength{\thumbtopmargin}{\ifshowcrop 3cm\else 1.5cm\fi} %1cm
\newlength{\thumbbottommargin}
\setlength{\thumbbottommargin}{\ifshowcrop 6cm\else 2cm\fi} %2.5cm
% calculate the box height by dividing the page height
\newlength{\thumbheight}
\pgfmathsetlength{\thumbheight}{%
(\paperheight-\thumbtopmargin-\thumbbottommargin)%
/%
\value{lettersum}
}
% box width
\newlength{\thumbwidth}
\setlength{\thumbwidth}{\ifshowcrop 2cm\else 0.5cm\fi} %0.5cm
% style the boxes
\tikzset{
thumb/.style={
   text=white,
   minimum height=\thumbheight,
   text width=\thumbwidth,
   outer sep=0pt,
   font=\sffamily\bfseries,
 }
 }

\def\thumbnew{}
\def\thumbold{}
\usepackage{everypage}
\AddEverypageHook{\if\relax\thumbnew\relax\xdef\thumbnew{\thumbold}\fi}

\def\ethumbs#1,#2\relax{\if\relax#1\relax\else\eventhumb{#1}\fi%
                        \if\relax#2\relax\else\ethumbs#2\relax\fi%
                        \gdef\thumbnew{}%
                        \gdef\thumbold{#1,}%
}

\def\othumbs#1,#2\relax{\if\relax#1\relax\else\oddthumb{#1}\fi%
                        \if\relax#2\relax\else\othumbs#2\relax\fi%
                        \gdef\thumbold{#1,}%
                        \gdef\thumbnew{}%
}

\newcommand{\drawthumb}[2]{%
  % see pgfmanual.pdf for more information about this part
  \begin{tikzpicture}[remember picture, overlay]
    \node [thumb, fill=\BoxColor{#1}, text centered, anchor=north #2]
       at ($(current page.north #2)-%
%            (0,\thumbtopmargin+\value{letternum}*\thumbheight)%
            (0,\thumbtopmargin+#1*\thumbheight)$) {\csname Let#1\endcsname};
   \end{tikzpicture}}
\fi

\newcommand{\oddthumb} [1]{\drawthumb{#1}{west}}
\newcommand{\eventhumb}[1]{\drawthumb{#1}{east}}

\newcommand{\lettergroup}[1]%
  {\refstepcounter{letternum}%
   \expandafter\gdef\csname Let\theletternum\endcsname{#1}%
   \xdef\thumbnew{\theletternum,\thumbnew}%
   \fancyhead[LO]{\phvfamily\bfseries\rightmark%
     \expandafter\ethumbs\thumbnew\relax\relax\relax}%
   \fancyhead[RE]{\phvfamily\bfseries\leftmark%
     \expandafter\othumbs\thumbnew\relax\relax\relax}}

答案1

\foreach以小组形式进行工作,这可能是造成您麻烦的原因,因为设置标记的时间或本地和全局分配。

尝试用\foreach替换

\makeatletter
\@for\next:=\alphabetF\do{\input{letters/\next.tex}}
\makeatother

当然你可以把它埋进宏里:

\makeatletter
\newcommand{\multiinput}[3][.tex]{%
  % #1 (optional) = extension, with leading .
  % #2 = prefix, such as `letters/`
  % #3 = comma separated list of items
  \@for\next:=#3\do{\input{#2/\next#1}}%
}
\makeatother

并称之为

\multiinput{letters/}{\alphabetF}

相关内容