我正在玩\@outputdblcol
,我想出了這個:
\documentclass[twocolumn]{article}
\makeatletter
\def\@outputdblcol{%
\if@firstcolumn
\global \@firstcolumnfalse
\global \setbox\@leftcolumn \box\@outputbox
\else
\global \@firstcolumntrue
\setbox\@outputbox \vbox {%
\hb@xt@\textwidth {%
\hskip\columnwidth
\hfil
{\normalcolor\vrule \@width\columnseprule}%
\hfil
\hb@xt@\columnwidth {%
\box\@outputbox \hss}%
\hskip-\textwidth
\hb@xt@\columnwidth {%
\box\@leftcolumn \hss}%
\hskip\columnwidth \hskip\columnsep
}%
}%
\@combinedblfloats
\@outputpage
\begingroup
\@dblfloatplacement
\@startdblcolumn
\@whilesw\if@fcolmade \fi
{\@outputpage
\@startdblcolumn}%
\endgroup
\fi
}
\makeatother
\pagestyle{headings}
\begin{document}
\tableofcontents
\section{Correct Headings}
Some useless text that we are provingin Some useless text that we are provingin Some useless text that we are provingin Some useless text that we are provingin
\section{Part}
Some useless text that we are provingin
\newpage
\section{Wrong Headings}
Some useless text that we are provingin
\section{Another Part}
Some useless text that we are provingin
\section{LAst Part}
Some useless text that we are provingin
\end{document}
但有趣的是,即使列的順序正確,但目錄卻亂序。為什麼會發生這種情況?以及應該如何解決它? (當然不改變\@outputdblcol
其原始形式的定義)?
使用大衛卡萊爾的建議,我遇到了完全相同的問題:
\documentclass[twocolumn]{article}
\TeXXeTstate=1
\makeatletter
\def\@outputdblcol{%
\if@firstcolumn
\global \@firstcolumnfalse
\global \setbox\@leftcolumn \box\@outputbox
\else
\global \@firstcolumntrue
\setbox\@outputbox \vbox {%
\hb@xt@\textwidth {\beginR%
\hb@xt@\columnwidth {%
\box\@leftcolumn \hss}%
\hfil
{\normalcolor\vrule \@width\columnseprule}%
\hfil
\hb@xt@\columnwidth {%
\box\@outputbox \hss}%
\endR}%
}%
\@combinedblfloats
\@outputpage
\begingroup
\@dblfloatplacement
\@startdblcolumn
\@whilesw\if@fcolmade \fi
{\@outputpage
\@startdblcolumn}%
\endgroup
\fi
}
\makeatother
\pagestyle{headings}
\begin{document}
\tableofcontents
\section{Correct Headings}
Some useless text that we are provingin Some useless text that we are provingin Some useless text that we are provingin Some useless text that we are provingin
\section{Part}
Some useless text that we are provingin
\newpage
\section{Wrong Headings}
Some useless text that we are provingin
\section{Another Part}
Some useless text that we are provingin
\section{LAst Part}
Some useless text that we are provingin
\end{document}
但這一個工作正常:
\documentclass[twocolumn]{article}
\TeXXeTstate=1
\makeatletter
\def\@outputdblcol{%
\if@firstcolumn
\global \@firstcolumnfalse
\global \setbox\@leftcolumn \box\@outputbox
\else
\global \@firstcolumntrue
\setbox\@outputbox \vbox {%
\hb@xt@\textwidth {%
\hskip\columnwidth
\hfil
{\normalcolor\vrule \@width\columnseprule}%
\hfil
\hb@xt@\columnwidth {%
\box\@leftcolumn \hss}%
\hskip-\textwidth
\hb@xt@\columnwidth {%
\box\@outputbox \hss}%
\hskip\columnwidth\hskip\columnsep }%
}%
\@combinedblfloats
\@outputpage
\begingroup
\@dblfloatplacement
\@startdblcolumn
\@whilesw\if@fcolmade \fi
{\@outputpage
\@startdblcolumn}%
\endgroup
\fi
}
\makeatother
\pagestyle{headings}
\begin{document}
\tableofcontents
\section{Correct Headings}
Some useless text that we are provingin Some useless text that we are provingin Some useless text that we are provingin Some useless text that we are provingin
\section{Part}
Some useless text that we are provingin
\newpage
\section{Wrong Headings}
Some useless text that we are provingin
\section{Another Part}
Some useless text that we are provingin
\section{LAst Part}
Some useless text that we are provingin
\end{document}
我只對如何修復前兩個範例中的 TOC 感興趣。
答案1
\shipout
使\write
寫入節點按照垂直列表中出現的順序,而不是按照視覺順序,因此,當您在視覺上交換列時,\hskip-\textwidth
這不會改變寫入順序。您可以不這樣做,而是不按自然順序輸出列,而是使用 xetex (或 luatex 等效項)指令來使用 RTL 設定嗎?
\hb@xt@\textwidth {\beginR%
..
我認為\beginR
是正確的這樣做的方法(但它不起作用)所以回到手動洗牌。這似乎有效:
\documentclass[twocolumn]{article}
\setlength\columnseprule{1pt}
\makeatletter
\TeXXeTstate=1
\makeatletter
\def\@outputdblcol{%
\if@firstcolumn
\global \@firstcolumnfalse
\global \setbox\@leftcolumn \box\@outputbox
\else
\global \@firstcolumntrue
\setbox\@outputbox \vbox {%
\hb@xt@\textwidth {%
\kern\textwidth\llap{\hb@xt@\columnwidth {%
\box\@leftcolumn \hss}}%
\kern-\textwidth
\rlap{\hb@xt@\columnwidth {%
\box\@outputbox \hss}}%
\hfil
{\normalcolor\vrule \@width\columnseprule}%
\hfil
}%
}%
\@combinedblfloats
\@outputpage
\begingroup
\@dblfloatplacement
\@startdblcolumn
\@whilesw\if@fcolmade \fi
{\@outputpage
\@startdblcolumn}%
\endgroup
\fi
}
\makeatother
\pagestyle{headings}
\begin{document}
\tableofcontents
\section{Correct Headings}
Some useless text that we are provingin Some useless text that we are provingin Some useless text that we are provingin Some useless text that we are provingin
\section{Part}
Some useless text that we are provingin
\newpage
\section{Wrong Headings}
Some useless text that we are provingin
\section{Another Part}
Some useless text that we are provingin
\section{LAst Part}
Some useless text that we are provingin
\end{document}