2列レイアウト、各言語ごとに2つの目次付き

2列レイアウト、各言語ごとに2つの目次付き

texliveDebian Jessie での使用

私はある職に応募する書類を作成しており、その内容をドイツ語と英語の両方のバージョンで含めたいと考えています。

ToCアプリケーションの表紙のすぐ後に、2 つの が並んでいるページを追加し、それぞれに指定された言語でのみ表示される内容を表示したいと考えています。

これまでのところ、次のように 2 つを追加する方法がわかりました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 の仕組みにあまり興味がないので、これからお願いしようとしていることが実現可能かどうかもわかりません。

最初の質問は次のとおりです。特定の条件を満たすエントリのみを表示するように ToC をカスタマイズすることは可能ですか?私の場合、条件は次のようになります。セクション名はドイツ語ですか、それとも英語ですか? ドイツ語の場合は左の ToC にのみ表示し、英語の場合は右の ToC にのみ表示します。さらに、エントリが両方の条件を満たして両方の ToC に表示できるとしたら素晴らしいと思います (たとえば、翻訳されていない証明書で、面白半分に 2 回追加する必要がないなど)。上記のすべてが、何らかの方法で機能しif、ドイツ語と英語のセクションに何らかの値を追加してチェックし、それに基づいて ToC に適切な値を入力すると想像できます。

この考え方を続けると、両方の言語に精通しているなら、上の画像でエントリが1と2同じ意味(ただし言語は異なる)であり、エントリも同様である3と4

これにより、2 番目の質問が生まれます。2 つのセクションに同じ番号を持たせることができるような条件を使用することは可能ですか?

最終的に、ページは次のようになります。

ここに画像の説明を入力してください


編集:素晴らしい @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]

説明が不十分だったような気がします (申し訳ありません!)。別の言語のセクションは、実際には別のセクションとして表示する必要があります。そのため、両方の に空白のエントリが残るという見た目の煩わしさはありますが、上記のコードは私のニーズに最も合っていますtoc。これらを削除することはできますか? 大したことではありませんが、このトピック全体の他の読者にとっては特に、両方の の 1 つに複数のエントリが表示され、もう 1 つにtoc大きな空白が残る大きなドキュメントで提供されているソリューションを使用したい場合、見た目がはるかに良くなると思いますtoc

答え1

\section以下は、目次のセクション名の英語版を保持する への追加のオプション引数を持つバージョンです。 が[...]省略されている場合、 には何も入力されませんftoc(つまりforeign toc)。

\tableofcontents従来の動作と他の言語に使用します\tableofcontents[ftoc]。言語設定は実際にはparcolumns環境内で行われ、\tableofcontentsetc内では行われません。

\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}

ここに画像の説明を入力してください

関連情報