I'm writing a LaTex document in which I must refer to some variables in some points of the document. In order to ensure that each variable is written in the same way, I defined a LaTex variable for each of them.
\documentclass[border=10pt]{standalone}
\usepackage{algorithm,algpseudocode}
\newcommand{\varu}{\emph{u}}
\newcommand{\varv}{\emph{v}}
\newcommand{\varz}{\emph{z}}
\newcommand{\varTr}{\emph{Training}}
\newcommand{\varRzT}{$R_{\varz_{\varTr}$ } }
\newcommand{\varReaz}{$R_{EAz}$ }
\newcommand{\varRecScore}{$s(\varv, \vart | \varu)$ }
\newcommand{\varCS}{Cand Set}
\newcommand{\varw}{\emph{w}(\varu,\varv)}
\newcommand{\varBC}{$\mathrm{BC}_{suff}$}
\begin{document}
My text is quite long. In the text there can
be referred some variables like \varu
which I would like is written as emph and after
the variable there is a white space.
Some of these variables are also inserted into
an algorithm structure defined with algorithm.
\end{document}
I use these variables in some points of the document: in the text, in math mode and into an algorithm structure.
My problem is that if I use these variables in the text, there is no white space after them. (i.e. after variable \varu
there is no space).
How can I resolve it?
I can't define \varu
with the white space \newcommand{\varu}{\emph{u }}
because when if the variable is followed by "." the white space is not correct.
$u$
not text italic (\textit{u}
) and certainly not as emphasis (which is usualy italic but could be any other styling depending on the class and context (\emph{u}
)\varu\
or\varu{}
to get space after the command name.