双栏文档中的目录顺序混乱

双栏文档中的目录顺序混乱

我在玩的\@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}

相关内容