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.

0

1 Answer 1

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}
3
  • 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} }. Commented Mar 11, 2019 at 18:58
  • Ask a new question. And add a sensible minimal example. Commented Mar 11, 2019 at 19:00
  • Okay, I did as you suggested → tex.stackexchange.com/questions/478958/… Commented Mar 11, 2019 at 19:51

You must log in to answer this question.

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