
나는 레이블을 "신뢰할 수 있게" 해야 하는 문제에 직면해 있습니다.
저는 텍스트의 다른 부분을 작성하기 위해 두 개의 다른 매개변수를 사용하여 tex 파일의 일부를 두 번 실행하는 메커니즘을 개발 중입니다. 이전에 설정된 변수와 함께 \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로 바꾸고 두 번째 경우에는 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}