3

I have some variables with multiple letter names like UA, US or ET. When I write the variables starting with an 'U' in math mode it seems like the space afterward the U is too large (look at the space between 'U' and 'A' below). Especially if I have other characters before the 'U' like a capital Delta:

\documentclass[11pt]{article}
\usepackage{lmodern}
\begin{document}
$US_t + \Delta UA_t - \Delta ET_t $
\end{document}

large space after U

10
  • 1
    Well, you could try \mathit{US} etc, but using more than one letter for a variable does not look nice, but that's perhaps only my point of view
    – user31729
    Commented Aug 5, 2016 at 10:50
  • 2
    I'd say that the general rule is if a var name is more than one letter, then it has to be written upright to avoid being confused with a product. I'd use something like \newcommand\US{\mathrm{US}} etc and then use \US. Then if you'd rather like \mathit as Christian suggests, then you can easily change that in a single place.
    – daleif
    Commented Aug 5, 2016 at 10:54
  • But is US a singlevariable name? There's a ΔU afterwards.
    – Bernard
    Commented Aug 5, 2016 at 10:56
  • @daleif: Or \newcommand{\tlvar}[1]{\mathrm{#1}} and saying \tlvar{US} etc. Means changing only the \tlvar macro (but has to change the inline occurences of US etc. of course)
    – user31729
    Commented Aug 5, 2016 at 10:56
  • @Bernard: Perhaps it is meant this way: \Delta (U A_{t}) rather? Only a guess...
    – user31729
    Commented Aug 5, 2016 at 10:58

3 Answers 3

4

I'd say that the general rule is if a var name is more than one letter, then it has to be written upright to avoid being confused with a product. I'd use something like \newcommand\US{\mathrm{US}} etc and then use \US. Then if you'd rather like \mathit as Christian suggests, then you can easily change that in a single place.

I've also included Christians suggestion of using \tlvar. I tend to prefer making direct macros as they are faster to type, and you are more free to define each like you want them. For example if you use a macro that ought to need some adjustments if a subscript is used on this particular macro, then you can use xparse to redefine this particular macro to do something extra.

\documentclass[a4paper]{article}

\newcommand\US{\mathrm{US}}
\newcommand\UA{\mathrm{UA}}
\newcommand\ET{\mathrm{ET}}
\newcommand\tlvar[1]{\mathrm{#1}}

\begin{document}
Version 1: $US_t + \Delta UA_t - \Delta ET_t $

Version 2: $\US_t + \Delta \UA_t - \Delta \ET_t $

Version 3: $\tlvar{US}_t + \Delta \tlvar{UA}_t - \Delta \tlvar{ET}_t $


\end{document}

Output

3
  • Thanks a lot @daleif. I have accepted your answer and edited it slightly to show others what the output would look like
    – Low
    Commented Aug 5, 2016 at 12:58
  • I don't agree with the statement that such variable names should be upright. Anyway, hiding them in macros allows for delaying the decision. You should change the first three definitions to use \tlvar rather than \mathrm.
    – egreg
    Commented Aug 5, 2016 at 13:06
  • @egreg leaving them in italic still leave them up for confusion
    – daleif
    Commented Aug 5, 2016 at 13:08
3

The essentiel answer on how to avoid that problem is given in the comments. Let's test OP's initial remark:

When I write the variables starting with an 'U' in math mode it seems like the space afterward the U is too large (look at the space between 'U' and 'A' below).

Let's see:

\documentclass[11pt]{article}
\usepackage{lmodern, amsmath}
\setlength{\fboxsep}{0pt}
\begin{document}
$US_t + \Delta UA_t - \Delta ET_t $

$\boxed{U}\boxed{S}_t + \boxed{\Delta} \boxed{U}\boxed{A}_t - \boxed{\Delta}\boxed{E}\boxed{T}_t $

\end{document}

enter image description here

LaTeX does add no extra space after italic U. No font kerning occurs at all, TeX basically puts box after box without considering the content and how well it fits together.

3
  • Thanks a lot for your answer! It's really interesting to see your \boxedapproach, did not know it existed and will certainly come in handy later. Would love to up vote it but unfortunately can't. However I have accepted @daleif's answer since it actually gives a solution. My question after all was not so much about if the spacing is in fact different but more about the fact that it seems different.
    – Low
    Commented Aug 5, 2016 at 13:00
  • @Low You should be able to upvote it (and others) now. Welcome to the site. Commented Aug 5, 2016 at 13:36
  • @Low No pb, as mentioned, it is not intended to be an answer to your problem, but I can't add an image to a comment. Commented Aug 5, 2016 at 16:21
1

The reason why it looks like there is more space after the U is because the top of the U goes further then the bottom. When u use emphasis the top part of the U will only extend more then when you write it in standard font.

You must log in to answer this question.

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