2

Through my research on this website I've found the best way to typeset multiletter variables is using \mathit. However, if the variable has mixed formatting (i.e. bold, italic and roman) or super/subscript the results are not satisfactory with regards to spacing.

For my case, I'm trying to denote perturbations (denoted $\delta$) to variables $f_0$ and $\bm{f}_1$. Simply prepending the delta creates too much space, while putting the entire group in \mathit affects the subscript spacing and the bold font. I have attached my best attempts as a MWE below.

It would be helpful if there was a command called \mathgroup or something that would denote a multiletter variable without affecting formatting.

\documentclass[preview]{standalone}
\usepackage{amsmath}
\usepackage{bm}
\begin{document}
% Case 1
$ \mathit{\delta f_\mathrm{0}}$ has less subscript spacing between $f$ and 0 than \\
$\delta f_0$ and even less than than \\
$ \mathit{\delta f}_0$

% Case 2: The only way I've found to achieve something close to what I want except for spacing
$\mathit{\delta \bm{{f_{\mbox{\unboldmath$\scriptstyle 1$}}}}} $ appears identical to \\
$ \delta \bm{f}_1$ the following are not solutions either\\
$ \mathit{\delta \bm{{f}}_\mathrm{1}}$ \\
$ \mathit{\delta \bm{{f}}}_1$
\end{document}

enter image description here

5
  • there are no multi-letter identifiers here, why use \mathit at all? Mar 29, 2017 at 21:43
  • @davidcarlisle \delta f_0 is a multi-letter identifier. I do not consider \delta to be an operator for my purposes. Therefore I require the spacing between the \delta and the f_0 to be reduced somehow. Perhaps \mathit isn't the right solution, but I haven't come across any others. Mar 29, 2017 at 21:48
  • 1
    mathematically perhaps, but not to tex, the reason to use mathit is that adjacent letters in the math italic font are designed to look separated so should not be used as a "word", but that does not apply to any of the examples here, Mar 29, 2017 at 21:51
  • \mathit is good for multiletter identifiers; here you seem to want kerning between \delta and f.
    – egreg
    Mar 29, 2017 at 21:51
  • @egreg Thanks for the tip. Kerning does work, but as I also have other places where I use the \delta notation I wanted to find a more consistent method than playing around with kerning for each different quantity that is perturbed. (For example, sometimes I have to use \mkern-1.5mu or \mkern-1mu to get satisfactory results, and was hoping this could be automated somehow.) Mar 29, 2017 at 21:55

2 Answers 2

3

You seem to want to kern the \delta with the next letter, pushing back an ‘f’ more than other letters.

I wouldn't do it, actually, but here's a proof of concept.

\documentclass{article}
\usepackage{amsmath,bm}

\makeatletter
\DeclareRobustCommand{\prt}{\mathop{}\!\delta\check@f}
\newcommand{\check@f}{%
  \@ifnextchar f{\mspace{-3mu}}{\check@bmf}%
}
\newcommand{\check@bmf}{%
  \@ifnextchar\bm{\check@bmf@i}{\mspace{-1.5mu}}%
}
\newcommand{\check@bmf@i}[2]{% #1 is \bm, #2 is the letter
  \if f\unexpanded{#2}%
    \mspace{-3mu}%
  \else
    \mspace{-1.5mu}%
  \fi
  \bm{#2}%
}
\makeatother

\begin{document}

$\prt g \prt f \prt\bm{f} \prt\bm{g}$

\end{document}

enter image description here

5
  • 2
    what no L3! I'm shocked. Mar 29, 2017 at 22:04
  • @DavidCarlisle “Proof of concept”. ;-)
    – egreg
    Mar 29, 2017 at 22:05
  • @egreg Thanks for coming up with this. While I half-agree with the statement that one 'shouldn't' do this (would you just use \delta and call it a day?), it definitely meets my original specs. Although perhaps the 'kerning table' might end up needing to be too complicated. However, I think half of my question stemmed from a misunderstanding of what the \mathit command really did. I presumed that normal math mode inserts extra space around every letter. Trying out your example and comparing with \mathit I found that the latter has no effect on \delta g which is not what I expected. Mar 29, 2017 at 22:26
  • @JonathanBrodrick With \mathit{\delta f} you get a different ‘f’, that's why it appears to be nearer the delta.
    – egreg
    Mar 29, 2017 at 22:28
  • @egreg Much clearer now thanks, should have done more reading around on \mathit I guess. Now I'll remember it changes letters not spacing. Mar 29, 2017 at 22:32
2

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}
\begin{document}

$ \delta f_0$ $ \delta \bm{f}_1$


$ \delta\!f_0$ $ \delta\!\bm{f}_1$


$ \delta \mkern-2mu f_0$ $ \delta \mkern-2mu \bm{f}_1$

\end{document}

\mathit is not appropriate here as there are no adjacent (latin) letters that need to be typeset as a word. i would probably use the first line, but if you want tighter spacing you can add a negative kern, I find the standard \! (-3mu by default) too much, but perhaps -2mu is an improvement.

2
  • Thanks David, I think this is probably the best solution, but was somehow hoping the kern amount could be automated. For another case even \delta\mkern-1.5mu\bm{Q} is too much, and it seems pretty painful to play around with kern amount for each variable... I realise I'm probably just being overly worried about these things... Mar 29, 2017 at 22:01
  • @JonathanBrodrick I would never put this in a document inline just use macros in each case \df \dbmf say defined as above then \dQ defined with a different value, then you only need to tune each letter once. Mar 29, 2017 at 22:03

You must log in to answer this question.

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