Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| composition:texte:symboles:pourquoi_ne_pas_utiliser_bf_et_it [2018/06/03 13:07] – joseph.wright | composition:texte:symboles:pourquoi_ne_pas_utiliser_bf_et_it [2021/01/08 23:05] (Version actuelle) – Suppression de la page désormais déplacée. yannick.tanguy | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | --- | ||
| - | title: What's wrong with `\bf`, `\it`, etc.? | ||
| - | category: usage | ||
| - | permalink: / | ||
| - | --- | ||
| - | |||
| - | The font-selection commands of LaTeX 2.09 were `\rm`, `\sf`, | ||
| - | `\tt`, `\it`, `\sl`, `\em` and `\bf`; they were modal | ||
| - | commands, so you used them as: | ||
| - | ```latex | ||
| - | {\bf Fred} was {\it here\/}. | ||
| - | ``` | ||
| - | with the font change enclosed in a group, so as to limit its effect; | ||
| - | note the italic correction command `\/` that was necessary at the | ||
| - | end of a section in italics. | ||
| - | |||
| - | At the release of LaTeX2e in summer 1994, these simple commands were | ||
| - | deprecated, but recognising that their use is deeply embedded in the | ||
| - | brains of LaTeX users, the commands themselves remain in LaTeX, | ||
| - | _with their LaTeX 2.09 semantics_. | ||
| - | the reason they were deprecated: each `_xx_` overrides | ||
| - | any other font settings, keeping only the size. So, for example, | ||
| - | ```latex | ||
| - | {\bf\it Here we are again\/} | ||
| - | ``` | ||
| - | ignores `\bf` and produces text in italic, medium weight (and the | ||
| - | italic correction has a real effect), whereas | ||
| - | ```latex | ||
| - | {\it\bf happy as can be\/} | ||
| - | ``` | ||
| - | ignores `\it` and produces upright text at bold weight (and the | ||
| - | italic correction has nothing to do). The same holds if you mix | ||
| - | LaTeX2e font selections with the old style commands: | ||
| - | ```latex | ||
| - | \textbf{\tt all good friends} | ||
| - | ``` | ||
| - | ignores the `\textbf` that encloses the text, and produces | ||
| - | typewriter text at medium weight. | ||
| - | |||
| - | So why are these commands deprecated?& | ||
| - | such as that in the last example. | ||
| - | commands are discussed in the rest of this answer. | ||
| - | |||
| - | LaTeX2e' | ||
| - | text-block commands. | ||
| - | `\mdseries` and `\bfseries`, | ||
| - | `\itshape`, `\scshape` and `\slshape`, and families | ||
| - | `\rmfamily`, | ||
| - | requires a family, a shape and a series (as well as a size, of | ||
| - | course). | ||
| - | ```latex | ||
| - | {\bfseries\ttfamily and jolly good company!} | ||
| - | ``` | ||
| - | produces bold typewriter text (but note the lack of a | ||
| - | [bold typewriter font](FAQ-bold-extras) | ||
| - | in the default Computer Modern fonts), or | ||
| - | ```latex | ||
| - | {\slshape\sffamily Never mind the weather\/} | ||
| - | ``` | ||
| - | (note the italic correction needed on slanted fonts, too). | ||
| - | |||
| - | LaTeX2e' | ||
| - | modal commands, and form a `\text`_`xx`_ command from | ||
| - | them. Thus `\bfseries` becomes `\textbf{text}`, | ||
| - | `\itshape` becomes `\textit{text}`, | ||
| - | becomes `\texttt{text}`. | ||
| - | ```latex | ||
| - | \textit{\textbf{Never mind the rain}} | ||
| - | ``` | ||
| - | to produce bold italic text (note that the block commands supply | ||
| - | italic corrections where necessary), and they be nested with the | ||
| - | LaTeX2e modal commands, too: | ||
| - | ```latex | ||
| - | \texttt{\bfseries So long as we're together} | ||
| - | ``` | ||
| - | for bold typewriter, or | ||
| - | ```latex | ||
| - | {\slshape \textbf{Whoops! | ||
| - | ``` | ||
| - | for a bold slanted instance of the current family (note the italic | ||
| - | correction applied at the end of the modal command group, again). | ||
| - | |||
| - | The new commands (as noted above) override commands of the same type. | ||
| - | In almost all cases, this merely excludes ludicrous ideas such as | ||
| - | " | ||
| - | couple of immediate oddities, though. | ||
| - | between `\itshape` (or `\slshape`) and `\scshape`: while many | ||
| - | claim that an italic small-caps font is typographically unsound, such | ||
| - | fonts do exist. | ||
| - | use of the instances in the [EC fonts](FAQ-ECfonts), | ||
| - | similar techniques could be brought to bear on many other font sets. | ||
| - | The second is the conflict between `\upshape` and `\itshape`: | ||
| - | Knuth actually offers an upright-italic font which LaTeX uses for | ||
| - | the " | ||
| - | sufficiently weird that, while there' | ||
| - | default LaTeX commands exist; to use the shape, the (eccentric) user | ||
| - | needs LaTeX' | ||
| - | ```latex | ||
| - | {\fontshape{ui}\selectfont Tra la la, di dee} | ||
| - | ``` | ||
| - | |||

