0

I'm facing an issue, where I need to "relable" lables.

I'm working on a mechanismn to run over a part of tex-file twice with two different parameters, in order to write out different parts of the text. By using \input with a variable set before. In the final PDF both arrangements should printed one after each other.

The mechanism works like this:

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

This creates me some problems, when I'm using labels. See here a simplified version (without \input, but with clear text)

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

I need something to rename the label mylabel to DE.mylabel in the first case and EN.mylabel in the second case.

I guess I somehow need to create an individual \label and \ref command? Any hint? Using this as is, leads of course to multiple defined labels

Georg

2
  • How are you getting\chapter{\lang}? Couldn't you also do \label{\lang mylabel}?
    – Teepeemm
    Dec 15, 2023 at 15:57
  • ok... that one was really simple.... thanks a lot..... sorry
    – Georg
    Dec 15, 2023 at 16:02

1 Answer 1

1

Thanks to @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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .