Relacionamento de etiquetas?

Relacionamento de etiquetas?

Estou enfrentando um problema em que preciso "conectar" os rótulos.

Estou trabalhando em um mecanismo para executar duas vezes uma parte do arquivo tex com dois parâmetros diferentes, a fim de escrever diferentes partes do texto. Usando \input com uma variável definida antes. No PDF final ambos os arranjos deverão ser impressos um após o outro.

O mecanismo funciona assim:

...
\DefCurrentLanguage{DE}
\input{content.tex}
\DefCurrentLanguage{EN}
\input{content.tex}
...

Isso me cria alguns problemas quando uso rótulos. Veja aqui uma versão simplificada (sem \input, mas com texto claro)

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

Preciso de algo para renomear o rótulo mylabel para DE.mylabel no primeiro caso e EN.mylabel no segundo caso.

Acho que de alguma forma preciso criar um comando individual \label e \ref? Alguma dica? Usar isso como está leva, é claro, a vários rótulos definidos

Jorge

Responder1

Obrigado a @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}

informação relacionada