3

The LaTeX2e font selection manual states

Commands defined by \DeclareTextFontCommand automatically take care of any necessary italic correction (on either side).

So running the following example

\documentclass{article}

\begin{document}

\showboxbreadth=\maxdimen
\showboxdepth=\maxdimen

f\textbf{H}f\showlists

f{\bfseries H}f\showlists

\end{document}

will produce the following relevant log

% for f\textbf{H}f
\OT1/cmr/m/n/10 f
\kern 0.77779
\OT1/cmr/bx/n/10 H
\kern 0.0
\OT1/cmr/m/n/10 f

% for f{\bfseries H}f
\OT1/cmr/m/n/10 f
\OT1/cmr/bx/n/10 H
\OT1/cmr/m/n/10 f

In certain applications, however, it is desired not to automatically insert the italic correction at all. How can I selectively/locally turn off the auto-insertion of italic correction from the \textXX{...} commands?

1 Answer 1

4

You can add \nocorr to suppress the italic correction at the beginning and/or at the end of a text command's argument:

\documentclass{article}

\begin{document}

\showboxbreadth=\maxdimen
\showboxdepth=\maxdimen
\tracingonline=1

f\textbf{\nocorr H\nocorr}f\showlists

f{\bfseries H}f\showlists

\end{document}

Prints for both hlists:

\hbox(0.0+0.0)x15.0
\OT1/cmr/m/n/10 f
\OT1/cmr/bx/n/10 H
\OT1/cmr/m/n/10 f
spacefactor 1000

From source2e.pdf (File w, ltfntcmd.dtx):

In addition to global customization of when to insert the italic correction, it is of course sometimes necessary to explicitly insert one with <code>\/</code>. It is also possible to suppress the italic correction in individual instances. For this, the command <code>\nocorr</code> is provided. The <code>\nocorr</code> must appear as the first or last token inside the braces of the argument of the <code>\text...</code> commands, at that end of the text where you wish to suppress the italic correction.

Or from usrguide.pdf, section 3.10 Font changing: text:

These are one-argument commands; they take as an argument the text which is to be typeset in the particular font. They also automatically insert italic corrections where appropriate; if you do not like the result, you can add an italic correction with <code>\/</code> or remove it with <code>\nocorr</code>. The <code>\nocorr</code> should always be the first or last thing within the <code>{<text>}</code> argument.

12
  • 2
    \nocorr has such a complicated definition:-) Jun 3, 2020 at 20:37
  • Ah yes, I forgot to check LaTeX2e for authors, where it says “… if you do not like the result, you can add an italic correction with \/ or remove it with \nocorr …” Seems like the information is quite scattered… Jun 3, 2020 at 20:42
  • @DavidCarlisle Now I understand why it was defined that way, lol Jun 3, 2020 at 20:46
  • @RuixiZhang Added the ursguide reference. The definition of \nocorr shows how you should not judge a macro by its definition ;-) Jun 3, 2020 at 20:54
  • @PhelypeOleinik Wait a second… If I wrote \textXX{\nocorr\nocorr}, then \text@command{\nocorr\nocorr} expands to \check@nocorr@ \nocorr\nocorr\nocorr\@nil, then \reserved@a would be the same as \reserved@b, and \reserved@c would be \@empty. But in this case only \check@icl is set to be empty. Things get worse for \textXX{\nocorr} Jun 3, 2020 at 22:48

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.