目录中的平行列文档的模拟布局

目录中的平行列文档的模拟布局

我有一个不寻常的文档布局,其中两个关于密切相关主题的部分并排设置。我希望章节和子部分以相同的并行方式显示在目录中,如下所示: 所需目录

(我知道部分编号重复,但我可以修复,这并不是问题的一部分。)

这不是我的目录目前的样子。我曾以为我可以通过重新定义\switchcolumn为来获得我想要的东西,当它展开时,也会写入\switchcolumnTOC。这是ParacolMWE 中使用的环境与正常环境之间的唯一区别paracol

\documentclass{article}
    \usepackage{kantlipsum,hyperref,paracol}
    \makeatletter
     \def\switchcolumn@i[#1]{
        \@ifstar{\addtocontents{toc}{\protect\switchcolumn[#1]*}\oldswitchcolumn[#1]}
                   {\addtocontents{toc}{\protect\switchcolumn[#1]}\oldswitchcolumn[#1]}
     }
     \newcommand\switchcolumn@ii{
        \@ifstar{\addtocontents{toc}{\protect\switchcolumn*}\oldswitchcolumn}
                   {\addtocontents{toc}{\protect\switchcolumn}\oldswitchcolumn}
     }
    \newenvironment{Paracol}[1]{%
        \addtocontents{toc}{\protect\begin{paracol}{#1}}
        \begin{paracol}{#1}
        \let\oldswitchcolumn\switchcolumn
        \def\switchcolumn{\kernel@ifnextchar[{\switchcolumn@i}{\switchcolumn@ii}}
    }
    {    \addtocontents{toc}{\protect\end{paracol}}
        \end{paracol}
    }
    \makeatother
    \begin{document}
    \tableofcontents
    \begin{Paracol}{2}
        \begin{column*}
          \section{Trees}
          \subsection{Silviculture of the Foo Tree} 
          \subsubsection{Habitat} \kant[1-2]
          \subsubsection{Uses} \kant[3]
          \subsubsection{Growth} \kant[4-5]
        \end{column*}

        \begin{column}
          \section{Pests}
          \subsection{Pests of the Foo Tree} 
          \subsubsection{Rats} \kant[1-2]
          \subsubsection{Cats} \kant[3]
          \subsubsection{Hats} \kant[4] 
        \end{column}

        \begin{column*}
          \subsection{Silviculture of the Bar Tree} 
        \end{column*}

        \begin{column}
          \subsection{Pests of the Bar Tree} 
        \end{column}
        \begin{column*}Lorem ipsum dolor sit...
          \subsubsection{Habitat} \kant[5]
          \subsubsection{Uses} \kant[6]
       \end{column*}
        %An image spanning the width of the page 
       \begin{nthcolumn}{0}%Continuation of bar tree silvics
           \subsubsection{Growth} \kant[7]
        \end{nthcolumn}

        \begin{column} Lorem ipsum dolor sit...
          \subsubsection{Pigs} \kant[6]
          \subsubsection{Wigs} \kant[7]
        \end{column}

    \end{Paracol}
\end{document}

不幸的是,我认为这些\switchcolumns 没有按照我期望的顺序展开,从而导致了下面的目录混乱。

\begin {paracol}{2}
\contentsline {section}{\numberline {1}Trees}{1}{section.1}
%Many more \contentslines from sections in both columns.
\contentsline {subsubsection}{\numberline {1.1.3}Hats}{3}{subsubsection.1.1.3}
\switchcolumn *
\contentsline {subsection}{\numberline {1.2}Pests of the Bar Tree}{3}{subsection.1.2}
\switchcolumn *
\switchcolumn 
\contentsline {subsection}{\numberline {1.2}Silviculture of the Bar Tree}{4}{subsection.1.2}
\switchcolumn 
\contentsline {subsubsection}{\numberline {1.2.1}Pigs}{4}{subsubsection.1.2.1}
%More \contentslines
\end {paracol}
\contentsline {subsubsection}{\numberline {1.2.2}Uses}{6}{subsubsection.1.2.2}
\switchcolumn [0]
\contentsline {subsubsection}{\numberline {1.2.3}Growth}{6}{subsubsection.1.2.3}
\switchcolumn 

我真的不知道如何解决这个问题。如果我希望内容仅在\section目录中的条目处对齐,我可以重新定义\addtocontents以将目录命令添加到\leftcontentsand\rightcontents宏中,然后使用这些宏在最后添加内容。但由于我希望它们在子节级别对齐,这将产生类似

    \begin{paracol}{2}
        \begin{column}\contentsline {section}{\numberline {1}Trees}{1}{section.1}\end{column}
        \begin{column}\contentsline {subsection}{\numberline {1.1}Silviculture of the Foo Tree}{1}{subsection.1.1}\end{column}
    %etc.
   \begin{column*}\contentsline {section}{\numberline {1}Pests}{1}{section.1}\end{column*}
        \begin{column*}\contentsline {subsection}{\numberline {1.1}Pests of the Foo Tree}{1}{subsection.1.1}\end{column*} 
    \end{paracol}

但结果仍然是错误的。

答案1

也许你可以用包来实现一些目标

出于某种原因,我不得不注释掉kantlipsum示例中的所有用法,因为这对混合物产生了奇怪的影响paracol+tableof(我没有试图理解)。

在下面的代码中,您可以修补columncolumn*环境以自动插入\TAGLEFT\TAGRIGHT

\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{kantlipsum,hyperref,paracol}
\usepackage{tableof}
\AtBeginDocument{\tofOpenTocFileForWrite}% see tableof doc, section 2.5

\def\TAGLEFT{\toftagstop{right}\toftagstart{left}}
\def\TAGRIGHT{\toftagstop{left}\toftagstart{right}}
\def\TAGLEFTRIGHT{\toftagstart{left}\toftagstart{right}}

\begin{document}\thispagestyle{empty}
\begin{paracol}{2}
  \begin{column*}
    \tableof{left}
  \end{column*}
  \begin{column}
    \tableof{right}
  \end{column}
\end{paracol}

% \tablenotof{left,right}

\begin{paracol}{2}

    \begin{column*}
\TAGLEFT
      \section{Trees}
      \subsection{Silviculture of the Foo Tree} 
      \subsubsection{Habitat} %\kant[1-2]
      \subsubsection{Uses}    %\kant[3]
      \subsubsection{Growth}  %\kant[4-5]
    \end{column*}

    \begin{column}
\TAGRIGHT
      \section{Pests}
      \subsection{Pests of the Foo Tree} 
      \subsubsection{Rats} %\kant[1-2]
      \subsubsection{Cats} %\kant[3]
      \subsubsection{Hats} %\kant[4] 
    \end{column}

    \begin{column*}
\TAGLEFT
      \subsection{Silviculture of the Bar Tree} 
    \end{column*}

    \begin{column}
\TAGRIGHT      \subsection{Pests of the Bar Tree} 
    \end{column}

\begin{column*}
\TAGLEFT
Lorem ipsum dolor sit...
  \subsubsection{Habitat} %\kant[5]
  \subsubsection{Uses}    %\kant[6]
\end{column*}

%An image spanning the width of the page 
\begin{nthcolumn}{0}%Continuation of bar tree silvics
\TAGLEFT
   \subsubsection{Growth} %\kant[7]
\end{nthcolumn}

\begin{column} Lorem ipsum dolor sit...
\TAGRIGHT
  \subsubsection{Pigs} %\kant[6]
  \subsubsection{Wigs} %\kant[7]
\end{column}
\end{paracol}
\end{document}

只有当两个目录具有相同数量的节、小节等时,它们的并行性才会继续...

引用

相关内容