1

I use XelaTeX to produce my CV.

Currently, I want to update it and have both Slovak and English CV within one document.

I want to have all strings of one language grouped in the preamble, same for the other. (That is, I don’t want to have the string after \begin{document}).

I want to create \cvlang using \def \cvlang {sk} % Options: en | sk. This way I can switch between languages quite easily.

Now, I have no idea, how to check what is the current value of the \cvlang. I want to create something like this (if syntax borrowed from Javascript; incorporated some TeX commands):

if (\cvlang == "sk"){
  \def \lgdatebirthplace {Dátum a miesto\\ narodenia}
  \def \lgaddress {Adresa}
  \def \lgphone {Telefón}
  \def \lgemail {Email}
}else if{
  \def \lgdatebirthplace {Date and place of birth}
  \def \lgaddress {Address}
  \def \lgphone {Phone}
  \def \lgemail {Email}
}

I don’t care about the package/command/syntax—it can be anything.

I tried to use ifthen package, but I’ve some errors at PDF compilation:

\usepackage{ifthen}
\ifthenelse{\equal{\lang}{sk}}{
    \def \lgdatebirthplace {Dátum a miesto\\ narodenia}
    \def \lgaddress {Adresa}
    \def \lgphone {Telefón}
    \def \lgemail {Email}
}{
  \def \lgdatebirthplace {Date and place of birth}
  \def \lgaddress {Address}
  \def \lgphone {Phone}
  \def \lgemail {Email}
}%

I tried to use pdftexcmds package, however, this does not work either:

% \usepackage{pdftexcmds}
% \ifnum\pdf@strcmp{\cvlang}{sk}{
  \def \lgdatebirthplace {Dátum a miesto\\ narodenia}
  \def \lgaddress {Adresa}
  \def \lgphone {Telefón}
  \def \lgemail {Email}
\else
  \def \lgdatebirthplace {Date and place of birth}
  \def \lgaddress {Address}
  \def \lgphone {Phone}
  \def \lgemail {Email}
\fi

Questions and answers I checked and tried to implement: - On testing two fully expanded character strings for equality

PS—I am quite new to TeX and I have never used any conditionals in it.

2

There is no need for ifthen here. Add your definitions to the babel interface:

\documentclass{book}
\usepackage[english]{babel}
%\usepackage[slovak]{babel}
\addto\extrasslovak{%
 \def \lgdatebirthplace {Dátum a miesto}}
\addto\extrasenglish{%
 \def \lgdatebirthplace {Date and place of birth}}

\begin{document}
\lgdatebirthplace

\end{document}
  • This works as expected, however, I use some of these ‘variables’ (i.e. command definitions that outputs a string) with hyperref packages, concreately with hypersetup, which now throughs errors (Undefined control sequence. <argument> \pdfauthor). It looks like this: \hypersetup{ pdfauthor={\pdfauthor}, pdftitle={\pdftitle}, pdfsubject={\pdfsubtitle}, pdfkeywords={\pdfkeywords}, pdfsubject={\pdfsubject} }. – tukusejssirs Mar 11 at 18:58
  • Ask a new question. And add a sensible minimal example. – Ulrike Fischer Mar 11 at 19:00
  • Okay, I did as you suggested → tex.stackexchange.com/questions/478958/… – tukusejssirs Mar 11 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.