
ラベルを「関連付ける」必要があるという問題に直面しています。
私は、テキストの異なる部分を書き出すために、2 つの異なるパラメータを使用して tex ファイルの一部を 2 回実行するメカニズムに取り組んでいます。 事前に変数を設定した \input を使用します。 最終的な PDF では、両方の配置が次々に印刷されるはずです。
このメカニズムは次のように機能します。
...
\DefCurrentLanguage{DE}
\input{content.tex}
\DefCurrentLanguage{EN}
\input{content.tex}
...
これは、ラベルを使用するときにいくつかの問題を引き起こします。ここでは、簡略化されたバージョン(\inputなし、ただしクリアテキスト)を参照してください。
\documentclass{scrbook}
\usepackage{etoc}
\usepackage{hyperref}
\counterwithout{section}{chapter}
\begin{document}
% Usually this is input my \input{myfile.txt} with the first option
\chapter{GERMAN}
\etocsettocstyle{\section*{Inhalt}}{}
\etocsettocdepth.toc{subsection}
\localtableofcontents
\setcounter{section}{0}
\section{Eins}
Referenz auf zwei: \ref{mylabel}
\subsection{Ein.Eins}
\section{Zwei}\label{mylabel}
% Usually this is input my \input{myfile.txt} with the second option
\chapter{ENGLISH}
\etocsettocstyle{\section*{Content}}{}
\etocsettocdepth.toc{subsection}
\localtableofcontents
\setcounter{section}{0}
\section{One}
Refenence to two: \ref{mylabel}
\subsection{One.One}
\section{Two}\label{mylabel}
\end{document}
最初のケースではラベル mylabel の名前を DE.mylabel に変更し、2 番目のケースでは EN.mylabel に変更する必要があります。
\labelと\refコマンドを個別に作成する必要があると思いますか?ヒントはありますか?これをそのまま使用すると、もちろん複数のラベルが定義されます
ゲオルグ
答え1
@Teepeemmに感謝します:
\documentclass{scrbook}
\usepackage{etoc}
\usepackage{hyperref}
\counterwithout{section}{chapter}
\begin{document}
% Usually this is input my \input{myfile.txt} with the first option
\def\lang {DE}
\chapter{GERMAN}
\etocsettocstyle{\section*{Inhalt}}{}
\etocsettocdepth.toc{subsection}
\localtableofcontents
\setcounter{section}{0}
\section{Eins}
Referenz auf zwei: \ref{\lang mylabel}
\subsection{Ein.Eins}
\section{Zwei}\label{\lang mylabel}
% Usually this is input my \input{myfile.txt} with the second option
\def\lang {EN}
\chapter{ENGLISH}
\etocsettocstyle{\section*{Content}}{}
\etocsettocdepth.toc{subsection}
\localtableofcontents
\setcounter{section}{0}
\section{One}
Refenence to two: \ref{\lang mylabel}
\subsection{One.One}
\section{Two}\label{\lang mylabel}
\end{document}