0

Example

% Based upon https://www.sharelatex.com/templates/cv-or-resume/professional-cv

%%%%%  Preamble  %%%%%

% Paper size = a4paper
% Text body font size = 12 pt
% Margins[all] = 1 in
% Page orientation = portrait
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
    \geometry{
    a4paper,
    left=1in,
    right=1in,
    top=1in,
    bottom=1in,
    portrait
    }

% Packages
\usepackage{hyperref}  % For metadata
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{titlesec}  % For custom paragraph style of headings

% Localisation-related variables
\def \cvlang {english}  % Options: english | slovak
\usepackage[\cvlang]{babel}

% Language independent variables
\def \cvname {Harry}
\def \cvsurname {Potter}
\def \cvbirthplace {London}
\def \cvaddress {4 Private Drive, Little Whinging, Surrey, England, Great Britain}
\def \cvphone {+44 7911 123456}
\def \cvemail {harrypotter@hogwarts.com}

% Slovak language variables
\addto\extrasslovak{%
    \def \cvbirthdate {31. 07. 1980}
    \def \pdfauthor {\cvname{} \cvsurname{}}
    \def \pdftitle {Životopis}
    \def \lgdatebirthplace {Dátum a miesto narodenia}
    \def \lgaddress {Adresa}
    \def \lgphone {Telefón}
    \def \lgemail {Email}
}

\addto\extrasenglish{%
    \def \cvbirthdate {31 July 1990}
    \def \pdfauthor {\cvname{} \cvsurname{}}
    \def \pdftitle {Curriculum Vitae}
    \def \lgdatebirthplace {Date and place of birth}
    \def \lgaddress {Address}
    \def \lgphone {Phone}
    \def \lgemail {Email}
}

% Font family
\usepackage[
        math-style=ISO,
        bold-style=ISO,
        partial=upright,
        nabla=upright
]{unicode-math}
\setmainfont{Libertinus Serif}
\setsansfont{Libertinus Sans}
\setmathfont{Libertinus Math}

% Paragraph and line settings
\setlength{\parindent}{0em}  % Set paragraph indentation
\setlength{\parskip}{0.15in}  % Paragraph spacing
\renewcommand{\baselinestretch}{1.5}  % Line spacing

% Setting metadata
\hypersetup{
    pdfauthor={\pdfauthor},
    pdftitle={\pdftitle},
    pdfsubject={\pdfsubtitle},
    pdfkeywords={\pdfkeywords},
    % pdfcreator={\pdfcreator},
    % pdfproducer={\pdfcreator},
    pdfsubject={\pdfsubject}
}

\title{\pdftitle}
\author{\pdfauthor}
\date{\today}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\section*{\cvname{} \textsc{\cvsurname{}}}

\begin{tabular}{rl}
    \textsc{\lgdatebirthplace{}:} & \cvbirthdate{}, \cvbirthplace{}\\
    \textsc{\lgaddress{}:}   & \cvaddress{}\\
    \textsc{\lgphone{}:}     & \cvphone{}\\
    \textsc{\lgemail{}:}     & \cvemail{}
\end{tabular}

\end{document}

I implemented this answer in order to have all language variants of my CV in one file.

All works as expected, however the hypersetup variables/commands (like pdfauthor) through errors while compilation (e.g. ! Undefined control sequence. <argument> \pdfauthor), here’s a log (I pressed enter every time the error showed up):

xelatex cv3.tex 
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2019/dev/Debian) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./cv3.tex
LaTeX2e <2018-04-01> patch level 5
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hxetex.def
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/puenc.def)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/stringenc.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def)))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/tuenc.def))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/share/texlive/texmf-dist/tex/latex/xltxtra/xltxtra.sty
(/usr/share/texlive/texmf-dist/tex/latex/realscripts/realscripts.sty)
(/usr/share/texlive/texmf-dist/tex/latex/metalogo/metalogo.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/xetex.def)))))
(/usr/share/texlive/texmf-dist/tex/latex/titlesec/titlesec.sty)
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty
(/usr/share/texlive/texmf-dist/tex/generic/babel/switch.def)
(/usr/share/texlive/texmf-dist/tex/generic/babel-english/english.ldf
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.def
(/usr/share/texlive/texmf-dist/tex/generic/babel/xebabel.def
(/usr/share/texlive/texmf-dist/tex/generic/babel/txtbabel.def)))))
(/usr/share/texlive/texmf-dist/tex/latex/unicode-math/unicode-math.sty
(/usr/share/texlive/texmf-dist/tex/latex/unicode-math/unicode-math-xetex.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
(/usr/share/texlive/texmf-dist/tex/latex/filehook/filehook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/fix-cm.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/unicode-math/unicode-math-table.tex)))
! Undefined control sequence.
<argument> \pdfauthor 

l.84 }

? 
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/se-ascii-print.def)
! Undefined control sequence.
<argument> \pdftitle 

l.84 }

? 
! Undefined control sequence.
<argument> \pdfsubtitle 

l.84 }

? 
! Undefined control sequence.
<argument> \pdfkeywords 

l.84 }

? 
! Undefined control sequence.
<argument> \pdfsubject 

l.84 }

? 
(./cv3.aux)
*geometry* driver: auto-detecting
*geometry* detected driver: xetex
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./cv3.out) (./cv3.out)
Overfull \hbox (14.30014pt too wide) in paragraph at lines 97--103
[] 
[1] (./cv3.aux)
 )
Output written on cv3.pdf (1 page).
Transcript written on cv3.log.
1

language are normally activated only a \begin{document}. That's then too late for your hyperref settings. So you need to call \selectlanguage yourself. Also carefully comment the end of lines in the language definitions, if you don't want to get spurious spaces everywhere. Don't use xltxtra, that's no longer needed today, and load hyperref late.

\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
    \geometry{
    a4paper,
    left=1in,
    right=1in,
    top=1in,
    bottom=1in,
    portrait
    }

\def \cvlang {english}  % Options: english | slovak
\usepackage[\cvlang]{babel}

% Packages
\usepackage{fontspec}
\usepackage{titlesec}  % For custom paragraph style of headings

% Localisation-related variables

% Language independent variables
\def \cvname {Harry}
\def \cvsurname {Potter}
\def \cvbirthplace {London}
\def \cvaddress {4 Private Drive, Little Whinging, Surrey, England, Great Britain}
\def \cvphone {+44 7911 123456}
\def \cvemail {harrypotter@hogwarts.com}

% Slovak language variables
\addto\extrasslovak{%
    \def \cvbirthdate {31. 07. 1980}%
    \def \pdfauthor {\cvname{} \cvsurname{}}%
    \def \pdftitle {Životopis}%
    \def \lgdatebirthplace {Dátum a miesto narodenia}%
    \def \lgaddress {Adresa}%
    \def \lgphone {Telefón}%
    \def \lgemail {Email}%
}

\addto\extrasenglish{%
    \def \cvbirthdate {31 July 1990}%
    \def \pdfauthor {\cvname{} \cvsurname{}}%
    \def \pdftitle {Curriculum Vitae}%
    \def \lgdatebirthplace {Date and place of birth}%
    \def \lgaddress {Address}%
    \def \lgphone {Phone}%
    \def \lgemail {Email}%
}

% Font family
\usepackage[
        math-style=ISO,
        bold-style=ISO,
        partial=upright,
        nabla=upright
]{unicode-math}
\setmainfont{Libertinus Serif}
\setsansfont{Libertinus Sans}
\setmathfont{Libertinus Math}

% Paragraph and line settings
\setlength{\parindent}{0em}  % Set paragraph indentation
\setlength{\parskip}{0.15in}  % Paragraph spacing
\renewcommand{\baselinestretch}{1.5}  % Line spacing

\expandafter\selectlanguage\expandafter{\cvlang}
\usepackage{hyperref}  % For metadata
% Setting metadata
\hypersetup{
    pdfauthor={\pdfauthor},
    pdftitle={\pdftitle},
    %pdfsubject={\pdfsubtitle},
    %pdfkeywords={\pdfkeywords},
    % pdfcreator={\pdfcreator},
    % pdfproducer={\pdfcreator},
    %pdfsubject={\pdfsubject}
}

\title{\pdftitle}
\author{\pdfauthor}
\date{\today}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\section*{\cvname{} \textsc{\cvsurname{}}}

\begin{tabular}{rl}
    \textsc{\lgdatebirthplace{}:} & \cvbirthdate{}, \cvbirthplace{}\\
    \textsc{\lgaddress{}:}   & \cvaddress{}\\
    \textsc{\lgphone{}:}     & \cvphone{}\\
    \textsc{\lgemail{}:}     & \cvemail{}
\end{tabular}

\end{document}
  • Hey everyone: @UlrikeFischer is TeX Genius! :) … Thank you for helping me out with both of my issues. :) – tukusejssirs Mar 11 at 20:05

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.