1

Toggle, Turn-on, and Turn-off

There are three types of behavior:

  1. TOGGLE Behavior

    • if italics were ON, turn italics OFF
    • if italics were OFF turn italics ON
  2. TURN ON Behavior
    • If already on, stays on.
    • if italic text mode is turned on, keep it on
    • if italic text mode was turned off, turn italics on
  3. TURN OFF Behavior
    • If already off, stays off.
    • if italic text mode is turned on, turn it off
    • if italic text mode was turned off, keep it off

Example of a Toggle Italics Command

\em has toggle behavior. Which letter As in the following source code snippet become italic in the output depends completely upon whether the first line is commented out or not.

% \em
AAA \em AAA \em AAA

We could get:

AAA AAA AAA

or

AAA AAA AAA

Question:

For Italicization, which command in LaTeX has turn-on behavior only?

9

1 Answer 1

4

Your idea that \em is a toggle is wrong. Its standard implementation is to change the shape from upright to italics or conversely, but it is not designed to perform that action. It can do anything, if the document class modifies its implementation. It is a generic command for emphasis, not for switching to italics; it happens that the common way to emphasize text is printing it in italics (or in upright if the current font is slanted).

So you should not rely on \em switching from upright to italics or conversely.

A correct definition of \em should be

\@nomath\em
<test>
  \eminnershape
\else
  <default action>
\fi

The standard <test> is \ifdim\fontdimen1\font>0pt, which returns true if the current font is slanted. The standard <default action> is \itshape.

The standard definition of \eminnershape is \upshape.

3
  • Alright, \em might not toggle between italics and non-italics, but it does toggle. I realize that you might defined "emphasized" text to be boldface instead of italic. In that case, \em toggles between boldface and non-boldface. Whether it be boldface, or italics, or something else, the behavior of using \em is completely dependent on whether \em was used an even or odd number of times in the earlier part of the document. If "emphasized" mode was turned on, \em it turns off. If it was off, it turns on. The question still remains, how do you get a turn-on-only version of \em? Commented Jan 13, 2019 at 1:06
  • @IdleCustard I continue to disagree. The standard implementation of \em seems to be like a toggle, but you should not rely on this as document classes are allowed to do whatever they prefer with \em.
    – egreg
    Commented Jan 13, 2019 at 10:49
  • Okay, my description of \em is wrong if someone implements \em in some strange way. There is a still a question, which command in LaTeX has turn-on behavior only for italics? Commented Jan 19, 2019 at 1:51

You must log in to answer this question.

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