7

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?

cfr
  • 198,882
kuuhkuuh
  • 498
  • 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 00:26
  • @Au101 Er ... really ? – cfr Apr 18 '16 at 00: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 00: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 00: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 01:07
  • @Au101 But any italic will have some glyphs which are 'simply slanted' i.e. oblique. You don't expect your commas and colons to have different shapes. How different each glyph looks from its upright counterpart is a matter for the font designer. I do agree that if none of the glyphs in a font are different from their oblique cousins, the font is not truly an italic. But I don't think you can apply that criterion to individual glyphs, but only to fonts. – cfr Apr 18 '16 at 01:20
  • @cfr I think that's true - I was probably trying to be cleverer than I am ;) I just looked at the title and thought: what would an "italic" § even look like? Well, like § I suppose, after all :P – Au101 Apr 18 '16 at 01:21
  • @Au101 I wouldn't think much of a font design in which the italic x looked like the oblique x, though, whatever the other glyphs looked like. I'd just count it as a bad italic x. So when does a bad italic font become a non-italic font ... ?? – cfr Apr 18 '16 at 01:26

2 Answers2

8

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

cfr
  • 198,882
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}