6

How is it possible in LaTeX to make the § be displayed in italics?

\textit{WGG \S\ 1 Allgemeines} 

is supposed to turn print like this:

WGG § 1 Allgemeines

but instead LaTeX gives me this:

WGG § 1 Allgemeines

Any ideas on how to solve this problem?

  • It's very important here not to confuse italics, which are supposed to look like the italic style of handwriting and are usually more ornate, more curly, and more embellished and which often have substantially different letter forms, with simple oblique text, where a slant is applied to the letters along with, perhaps, a few minor surface changes. An italic version of § doesn't seem to exist in Computer Modern and that isn't too surprising. However, an oblique (\textsl{}) version doesn't seem to exist either. You could fake one with XeTeX or use it to get a different font – Au101 Apr 18 '16 at 0:26
  • @Au101 Er ... really ? – cfr Apr 18 '16 at 0:33
  • Welcome! Note that it is usually much better to give a complete, compilable example rather than a code fragment. – cfr Apr 18 '16 at 0:34
  • Note that this is not the same as the symbol used for paragraphs, so I've edited your question. Feel free to roll-back if you think I've misunderstood your question. – cfr Apr 18 '16 at 0:36
  • @cfr I didn't know about using the T1 encoding - good answer, I've already upvoted. However, I would say that your § certainly seems to be simply a slated form of § (which is more than fit for purpose), rather than some kind of true italic form, unlike, for example, x versus \textit{x}. But no I'm pleased and surprised it was so easy, you deserve the tick :) – Au101 Apr 18 '16 at 1:07
7

Use the T1 rather than OT1 font encoding:

\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
  \S 1 \textit{\S 1}
\end{document}

In this case, the symbol is taken from the same font as is used for regular text (whatever the current font is - upright, italic, whatever) rather than from a distinct symbol font. This is because T1, unlike OT1, has 256 rather than 128 slots and, therefore, room for such luxuries. With only 128 slots, extras get accommodated by pulling them from separate fonts and do not necessarily match the style of the surrounding text for this reason.

T1

| improve this answer | |
2

If one did not prefer T1 encoding, and was using pdflatex, the other option is to use Bruno's \slantbox (Shear transform a "box").

\documentclass{article}
\newsavebox\foobox
\newcommand{\slantbox}[2][.2]{\mbox{%
        \sbox{\foobox}{#2}%
        \hskip\wd\foobox
        \pdfsave
        \pdfsetmatrix{1 0 #1 1}%
        \llap{\usebox{\foobox}}%
        \pdfrestore
}}
\begin{document}
Here is the section sign, \S,\\ and here it is slanted: \slantbox{\S}.
\end{document}

enter image description here

ADDENDUM

The OP, in a comment, indicates an issue with not wanting the symbol slanted in the toc. This gives the impression that the symbol is being used in a section name. It can be easily arranged as follows, to appear unslanted in the toc and slanted in section titles.

If it only shows up once or twice, the optional argument to \section can be used:

\documentclass{article}
\newsavebox\foobox
\newcommand{\slantbox}[2][.2]{\mbox{%
        \sbox{\foobox}{#2}%
        \hskip\wd\foobox
        \pdfsave
        \pdfsetmatrix{1 0 #1 1}%
        \llap{\usebox{\foobox}}%
        \pdfrestore
}}
\begin{document}
\tableofcontents

\noindent\hrulefill

\section[Here is a section symbol \S]{Here is a section symbol \slantbox{\S}}
\end{document}

If it is regularly occurring symbol, this redefinition approach will suffice.

\documentclass{article}
\newsavebox\foobox
\newcommand{\slantbox}[2][.2]{\mbox{%
        \sbox{\foobox}{#2}%
        \hskip\wd\foobox
        \pdfsave
        \pdfsetmatrix{1 0 #1 1}%
        \llap{\usebox{\foobox}}%
        \pdfrestore
}}
\newcommand\slanted[2][]{#2}
\begin{document}
\tableofcontents
\renewcommand\slanted[2][.2]{\slantbox[#1]{#2}}

\noindent\hrulefill

\section{Here is a section symbol \slanted{\S}}
\end{document}
| improve this answer | |
  • @kuuhkuuh Note that the optional argument to \slantbox provides the amount of slant (negative for leftward slant). The arctangent of the slant value gives the angle of slant. – Steven B. Segletes Apr 18 '16 at 13:29
  • Well, now theres another issue: the style of the § is now also changed in the TOC, which shouldn't happen, as the TOC is otherwise not in italics. Any ideas? – kuuhkuuh Apr 18 '16 at 14:43
  • @kuuhkuuh So that I understand, is the issue that this symbol is used in a section name? – Steven B. Segletes Apr 18 '16 at 14:50
  • @kuuhkuuh Please see my addendum, to see if it addresses your need. – Steven B. Segletes Apr 18 '16 at 15:10
  • 1
    @kuuhkuuh Oh well, easy come, easy go. – Steven B. Segletes Apr 18 '16 at 15:28

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.