7

I'm using OT1 font encoding, but I would like to use T1 font encoding for glyphs that don't exist in OT1. To do that, I'm redefining the typical T1 commands so that they automatically choose a T1 encoding. With the commands for accented letters, however, like \'e for é, using \newcommand{\'e} won't work because \' is already defined, but I can't use \renewcommand{\'e} either, since the full sequence \'e is not already defined.

Suggestions?

\documentclass{article}
\usepackage[T1, OT1]{fontenc}
%\newcommand{\'e}{\fontencoding{T1}\selectfont{\symbol{233}}} <- gives 'Command \' already defined' error
%\renewcommand{\'e}{\fontencoding{T1}\selectfont{\symbol{233}}} <- gives '\'eundefined' error
\begin{document}
\'e
\end{document}

EDIT:

Given all the comments about the OT1 vs. T1 encoding, here's the contents of the OT1 and T1 fonts for libertine. One can see here that the OT1 font has some ligatures the T1 font doesn't have:

\documentclass{article}
\usepackage{fonttable}
\begin{document}
\fonttable{LinLibertineT-lf-ot1} % OT1 encoding
\fonttable{LinLibertineT-lf-t1} % T1 encoding
\end{document}

enter image description here enter image description here

11
  • I'm confused by the aim here: LaTeX gives you a combined accent and e in OT1 here already, while if you want to have a single glyph, you can just use T1 generally. What is the reason for wanting to use OT1/T1 in this way?
    – Joseph Wright
    Sep 6, 2013 at 10:20
  • This has no advantage, other than, perhaps, getting a sligthly better output; but you'll be mixing different fonts, so hyphenation will still not be possible.
    – egreg
    Sep 6, 2013 at 10:21
  • @JosephWright: My reasons for wanting to use OT1 generally are explained here: tex.stackexchange.com/questions/130541/…. In short, OT1 has some glyphs T1 doesn't have, and T1 has some glyphs OT1 doesn't have. The OT1 combination of accent+e is ugly in the libertine font, so I want to use the T1 non-combined glyph.
    – Sverre
    Sep 6, 2013 at 10:22
  • @Sverre Why don't you use T1 and forget about all the rest?
    – egreg
    Sep 6, 2013 at 10:25
  • 1
    @JosephWright: The main difference between OT1 and T1 is that T1 is full: on all 256 positions there is a glyph. In OT1 there are 128 "free" position which fonts can use for special glyphs/special effects. Sep 6, 2013 at 10:46

1 Answer 1

6

You can, but wouldn't it be simpler to switch to the T1 encoding?

\documentclass{article}
\usepackage[T1,OT1]{fontenc}
\usepackage{libertine}

\DeclareTextCompositeCommand{\'}{OT1}{e}{{\fontencoding{T1}\selectfont\'e}}

\begin{document}

a\accent19 ei % the original one

a\'ei

\end{document}

enter image description here

You can easily extend to all desired combinations using the same pattern. Note that you can even use \'e in the definition, since the encoding will already be T1 in the group, so the combination \'e will use the relative definition.

4
  • @Sverre The switch to T1 must be local, therefore the additional pair of braces. Notice that I simplified the definition, so you don't even have to hunt through the table to find code points.
    – egreg
    Sep 6, 2013 at 10:43
  • I see. I always enclose my macros (e.g. {\'e}) within brackets anyway, so the T1 encoding will be local. But I see that if I don't do that, it'll remain T1.
    – Sverre
    Sep 6, 2013 at 10:52
  • The reason I went through the table to find the code points was that a redefinition such as \renewcommand{\aa}{\fontencoding{T1}\selectfont{\aa}} didn't work. I needed to do \renewcommand{\aa}{\fontencoding{T1}\selectfont{\symbol{229}}}.
    – Sverre
    Sep 6, 2013 at 10:55
  • @Sverre Of course you can't use \aa in the definition of \aa; however, \DeclareTextCompositeCommand{\'}{OT1}{e}{...} doesn't define a \'e command, so using \'e in the body is possible, as long as the encoding is set to a different one than in the second argument.
    – egreg
    Sep 6, 2013 at 10:58

You must log in to answer this question.

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