兩欄佈局,每種語言都有雙語兩個目錄

兩欄佈局,每種語言都有雙語兩個目錄

texlive在 Debian Jessie使用

我正在撰寫職位申請,並希望包含德語和英語版本的內容。

我希望在我的應用程式封面後面有一個頁面,其中包含兩個ToC彼此相鄰的 s,但每個頁面僅顯示指定語言的內容。

到目前為止,我已經找到瞭如何添加兩個ToC這樣的:

\usepackage{parcolumns}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\pc@placeboxes}{\vrule}{{\VRULE}}{}{}
\makeatother
\newcommand\VRULE{\color{SOME_COLOR}\vrule width 0.2mm}
\usepackage{shorttoc}
...

\begin{parcolumns}[nofirstindent,rulebetween=true]{2}
    \colchunk{
        \selectlanguage{german}
        \shorttableofcontents{\contentsname}{1}
    }
    \colchunk{
        \selectlanguage{english}
        \tableofcontents
    }
\end{parcolumns}
\pagebreak

這會產生以下結果:

在此輸入影像描述

如您所見,事情還遠未完成。我不太喜歡 LaTeX 的花招,所以我不知道我所要求的是否可能。

第一個問題是:是否可以自訂目錄以僅顯示符合特定條件的條目?就我而言,條件是:部分名稱是德語還是英語?如果是德語,則僅在左側目錄中顯示,否則如果是英語,則僅在右側目錄中顯示。此外,如果一個條目可以滿足這兩個條件,以便它可以出現在兩個目錄中,那就太棒了(例如,我沒有翻譯的證書,並且不需要僅僅為了好玩而將其添加兩次)。我想以上所有內容都可以與某種類型一起使用if,並為德語和英語部分添加某種值,然後檢查該值並根據它相應地填充目錄。

繼續這個思路,如果您熟悉這兩種語言,您可能已經注意到上圖中的條目1 和 2意思相同(但語言不同)以及條目3和4

這引出了第二個問題,即:是否可以使用某種條件來允許兩個部分具有相同的編號?

最後頁面應該是這樣的:

在此輸入影像描述


編輯:感謝令人驚嘆的@ChristianHupfer,它幾乎完成了!最後一個問題是刪除toc沒有條目 X、Y 和 Z 但ftoc有條目的空白條目:

在此輸入影像描述

上圖對應下面的程式碼:

\section{Lebenslauf}
\pagebreak
\section{Lebenslauf}[CV]*
\pagebreak
\section{Bachelor Urkunde}
\pagebreak
\section{Bachelor Urkunde}[Bachelor Diploma]*
\pagebreak
\section{Lalalala}[Lalalala]
\pagebreak
\section{Wichtige Informationen}
\pagebreak
\section{Wichtige Informationen}[Important information]*
\pagebreak
\section{Andere Informationen}
\pagebreak
\section{Noch mehr wichtige Informationen}
\pagebreak
\section{Noch mehr wichtige Informationen}[Even more important information]*
\pagebreak
\section{Blabla}[Only in English Foo]*
\pagebreak
\section{Zusammengef\"uhrt}[Recombined]

我有一種感覺,我可能沒有很好地解釋事情(對此感到抱歉!) - 使用不同語言的部分實際上必須作為單獨的部分出現。因此,上面的程式碼最適合我的需求,因為兩個tocs 中都留有空白條目,這在視覺上造成了一些小麻煩。是否可以刪除這些?這不是什麼大問題,但我相信事情看起來會好得多,特別是對於整個主題的其他讀者來說,他們想要使用更大文檔中提供的解決方案,其中多個條目可以只出現在兩個toc文檔中的一個中,留下巨大的內容其他的空格toc

答案1

這是一個帶有附加可選參數的版本,其中\section包含內容表的節名稱的英文版本。如果[...]省略 ,則不會在 中輸入任何內容ftoc(意思是foreign toc)。

用於\tableofcontents傳統行為和\tableofcontents[ftoc]其他語言。語言設定實際上是在parcolumns環境中完成的,而不是在\tableofcontents等內部完成的。

\documentclass{article}

\usepackage[english,ngerman]{babel}
\usepackage{xpatch}
\usepackage{xparse}


\usepackage{parcolumns}


\makeatletter

\patchcmd{\pc@placeboxes}{\vrule}{{\VRULE}}{}{}
\newcommand\VRULE{\color{SOME_COLOR}\vrule width 0.2mm}


\let\latex@@section\section
\RenewDocumentCommand{\section}{somo}{%
  \IfBooleanTF{#1}{%
    \latex@@section*{#3}%
  }{%
    \IfValueTF{#2}{%
      \latex@@section[#2]{#3}%
    }{%
      \latex@@section{#3}%
    }%
    \IfValueT{#4}{%
      \addcontentsline{ftoc}{section}{\protect\numberline{\csname thesection\endcsname}#4}
    }%
  }%
}

\renewcommand\tableofcontents[1][toc]{%
  \section*{\contentsname
    \@mkboth{%
      \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
  \@starttoc{#1}%
}



\makeatother  

\begin{document}

\begin{parcolumns}[nofirstindent,rulebetween=true]{2}
    \colchunk{
        \selectlanguage{ngerman}
        \tableofcontents
        %\shorttableofcontents{\contentsname}{1}
    }
    \colchunk{
        \selectlanguage{english}
        \tableofcontents[ftoc]
    }
\end{parcolumns}
\pagebreak

\section{Lebenslauf}[CV]
\section{Bachelor Urkunde}[Bachelor Diploma]
\section{Wichtige Informationen}[Important information]





\end{document}

在此輸入影像描述

更新

\documentclass{article}

\usepackage[english,ngerman]{babel}
\usepackage{xpatch}
\usepackage{xparse}


\usepackage{parcolumns}


\makeatletter

\patchcmd{\pc@placeboxes}{\vrule}{{\VRULE}}{}{}
\newcommand\VRULE{\color{SOME_COLOR}\vrule width 0.2mm}

\newcounter{storetocdepth}

\let\latex@@section\section
\RenewDocumentCommand{\section}{somos}{%
  \IfBooleanTF{#1}{%
    \latex@@section*{#3}%
  }{%
    \IfBooleanTF{#5}{%
      \setcounter{storetocdepth}{\value{tocdepth}}
      \addtocontents{toc}{\protect\setcounter{tocdepth}{-4}} 
      % The #2 is of no use here, except of page headings /section mark
      \IfValueTF{#2}{%
        \latex@@section[#2]{#3}%
      }{%
        \latex@@section{#3}%
      }%
      \addtocontents{toc}{\protect\setcounter{tocdepth}{\number\value{storetocdepth}}}
      \addtocontents{toc}{\protect\contentsline{section}{\protect\phantom{#3}}{}}% Provide an empty fake entry
    }{%
      \IfValueTF{#2}{%
        \latex@@section[#2]{#3}%
      }{%
        \latex@@section{#3}%
      }%
    }%
    \IfValueTF{#4}{%
      \addcontentsline{ftoc}{section}{\protect\numberline{\csname thesection\endcsname}#4}
    }{%
      \addtocontents{ftoc}{\protect\contentsline{section}{\protect\phantom{#2}}{}}% Provide an empty fake entry
    }%
  }%
}

\renewcommand\tableofcontents[1][toc]{%
  \section*{\contentsname
    \@mkboth{%
      \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
  \@starttoc{#1}%
}



\makeatother  

\begin{document}

\begin{parcolumns}[nofirstindent,rulebetween=true]{2}
    \colchunk{
        \selectlanguage{ngerman}
        \tableofcontents
        %\shorttableofcontents{\contentsname}{1}
    }
    \colchunk{
        \selectlanguage{english}
        \tableofcontents[ftoc]
    }
\end{parcolumns}
\pagebreak

\section{Lebenslauf}[CV]
\section{Bachelor Urkunde}[Bachelor Diploma]
\section{Wichtige Informationen}[Important information]
\section{Andere Informationen}
\section{Noch mehr wichtige Informationen}[Even more important information]
\section{Blabla}[Only in English Foo]*

\section{Zusammengef\"uhrt}[Recombined]




\end{document}

在此輸入影像描述

相關內容