Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to have the pound sign appear in text composed with TG Pagella.

\documentclass[11pt]{article}
\usepackage{tgpagella} % alternative to MinionPro
%\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
  The pound sign one way : \pounds, or another \textsterling
\end{document}

produces a dollar sign. however if I change [utf8]{inputenc} into [t1]{fontenc}, I do get a nice pound sign. question: Why is that so? doesn't Pagella support utf8? Is it OK to use T1 and fontenc together with Pagella? Any issues?

share|improve this question
2  
See tex.stackexchange.com/questions/44694/fontenc-vs-inputenc for the difference between inputenc and fontenc: both are useful, but for separate tasks. –  Joseph Wright Mar 13 at 17:59

2 Answers 2

As JosephWright explained, you can perfectly well use both inputenc and fontenc:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}% generally best to load this before loading the font
\usepackage{tgpagella}% alternative to MinionPro
\usepackage[utf8]{inputenc}
\begin{document}
  The pound sign one way : \pounds, or another \textsterling
\end{document}

inputenc sets the input encoding i.e. how the characters you type are encoded. fontenc sets the output encoding which tells TeX where in the font particular glyphs should be.

The reason you get a dollar sign when you do not load fontenc with the T1 encoding is that you are then using the default encoding, OT1 and there appears to be at least one bug, but probably two, in the font configuration for tgpagella (and probably the other TeX-Gyre fonts since they all share the same encoding files).

OT1 only has 128 slots whereas T1 has 256. This means that there is not room for both the dollar and pound sign. Originally, TeX could not deal with encodings containing more than 128 characters. The way TeX originally coped with this limitation was to put the dollar sign in the upright font and the pound sign in the italic. So if OT1 is active (e.g. because you don't load fontenc with another encoding), your code will produce dollar signs instead of pound signs because the dollar occupies that slot in the upright font. To avoid this, LaTeX uses the following code:

\DeclareTextCommand{\textsterling}{OT1}{\hmode@bgroup
   \ifdim \fontdimen\@ne\font >\z@
      \itshape
   \else
      \fontshape{ui}\selectfont
   \fi
   \char`\$\egroup}

and further defines \pounds in terms of either \mathsterling or \textsterling depending on whether you are in maths mode or not.

So \pounds and \textsterling should behave as expected. However, it does not. For some reason, TeX tries to load the ui shape for tgpagella. Since this doesn't exist, it substitutes the upright shape which, of course, gives you the dollar sign. This suggests that the relevant font dimension has not be set correctly as the code should cause it to try \itshape rather than attempting to load the non-existent ui shape. However, even if you force \itshape, you do not get a sterling sign but, rather, an italic dollar. So the configuration has apparently put an italic dollar in the italic font for the OT1 encoding rather than the upright sterling sign.

Avoiding such complexities is one reason T1 is recommended. Others include the fact that many accented characters are included in T1 whereas if you use OT1, TeX has to create them from the unaccented glyph plus an accent. This is less satisfactory in terms of both the visual appearance (in many cases) and copy-and-paste. Again, this is because of limitations imposed by the 128 slot limit.

share|improve this answer
    
@DavidCarlisle You're right. See my corrections. I think there are two bugs in tgpagella. –  cfr Mar 13 at 19:33

Don't ignore latex warnings:-)

\documentclass[11pt]{article}
\usepackage[OT1]{fontenc}% generally best to load this before loading the font
\usepackage{tgpagella}% alternative to MinionPro
\usepackage[utf8]{inputenc}
\begin{document}
  The pound sign one way : \pounds, or another \textsterling
\end{document}

Produces

LaTeX Font Warning: Font shape `OT1/qpl/m/ui' undefined
(Font)              using `OT1/qpl/m/n' instead on input line 6.

In OT1 encoding, italic fonts have a £ and non italic fonts have a $ So LaTeX2e, to avoid having a default slanted £ (as LaTeX2.09 and plain TeX did) uses an upright italic font. But most font sets don't have that so the font mechanism is substituting it

It is unfortunately substituting upright roman (m/n) so losing the pound, it would be better to substitute italic

You could add

\AtBeginDocument{\DeclareFontShape{OT1}{qpl}{m}{ui}{<->sub*qpl/m/it}{}}

then the substitution is

LaTeX Font Warning: Font shape `OT1/qpl/m/ui' in size <10.95> not available
(Font)              Font shape `OT1/qpl/m/it' tried instead on input line 7.

But it seems that you still get a $ which is arguably an error in teh internal font encoding for OT1 in this font, but really there is no reason to use OT1 encoding at all, it is just there to cope with the interesting features of the encodings used by the Computer Modern fonts, so switching to T1 makes the problem go away.

share|improve this answer
    
It isn't LaTeX's fault it is substituting ui, I don't think. I believe this is due to a second bug in tgpagella. What LaTeX does is actually dependent on a font dimension which I think must be configured incorrectly in this case. Otherwise, you would see this problem for any font lacking the ui shape. But you don't. (The standard Times look-alike, for example, gets this right but there is no ui shape.) So if it were set correctly, it would try \itshape given the code from the base configuration for OT1. (See my edited answer.) –  cfr Mar 13 at 19:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.