5

I have to Amino acids as variable-names within LaTeX. So far I am using (and found out):

\documentclass{a4paper}{article}
\newcommand\dTRP{\mathit{d-TRP}}
\begin{document}
    $[\dTRP] = 3$ (Ignore the missing units :-) - MWE )
\end{document}

The hyphen between "d" and "TRP" is just too long and seems to contain small spaces between "d" and "TRP" which is not very appealing to me and I suppose that I didn't do it the genuine way.

0

1 Answer 1

9

You should use \textit instead of \mathit.

With \mathit, the tex engine interprets the groups of characters as "words" (compare, for example the output of $TRP$ and $\mathit{TRP}$), but non-letter characters are still denoting the mathematical symbol. In particular, here, the hyphen is a minus. The glyph is different, and the spacing is different.

On the other hand, \textit deals with elements of text, so words in the usual sense (so, possibly-containing hyphens).

To sum up:

  • $d-TRP$ should mean "variable d minus variable T times variable R times variable P"
  • $\mathit{d-DRP}$ should mean "variable d minus variable TRP" (and is poorly coded for that purpose)
  • $\textit{d-TRP}$ should mean "variable d-TRP"

Edit: To have \textit scaled normally in sub- and super-script, you should load the amsmath package. Thanks to David Carlisle for reminding me that, and for pointing my mistake about spacing around characters in \mathit.

4
  • 1
    well yes and no, the letter spacing for \mathit is the same as \textit it uses the text italic font, not math italic, so does not have the wide sidebearings and lack of ligatures. But it is the case that - is a minus sign. Note if using \textit you should load amsmath otherwise it won't get smaller in subscripts. Apr 29, 2013 at 13:23
  • thank you very much. I will accept your answer in 3 Minutes (Forum rules...) :-) Apr 29, 2013 at 13:29
  • @DavidCarlisle Thank you indeed for the mention of amsmath, I added it. Your point about the spacing surprises me more, though: do you mean that \mathit is really designed for word-like variables, as long as they contain no punctuation mark?
    – T. Verron
    Apr 29, 2013 at 13:29
  • @T.Verron yes essentially. Although "design" is perhaps putting it too strong, it does what \it does in plain TeX in math mode, just as \mathrm does what \rm does. In both cases they use a text font but in a math setting. Unlike the \mathnormal (\mit in plain Tex) which is math italic. Apr 29, 2013 at 14:15

You must log in to answer this question.

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