9

I'm using Springers svmono for a book with many mathematical symbols and special characters.

There are quite a few problems with characters that are simply not printed (using pdfLatex), so I tried to add utf8 support:

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

However, there are errors. This is a MWE (svmono.cls needed to make it run):

%%%%%%%%%%%%%%%%%%%% book.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% sample root file for the chapters of your "monograph"
%
% Use this file as a template for your own input.
%
%%%%%%%%%%%%%%%% Springer-Verlag %%%%%%%%%%%%%%%%%%%%%%%%%%


% RE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[graybox,envcountchap,sectrefs]{svmono}

% choose options for [] as required from the list
% in the Reference Guide

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\begin{document}

\begin{verbatim}
   # sin(π * t)
\end{verbatim}

Kudos (κῦδος)

\end{document}

Using utf8x I get:

ERROR: Undefined control sequence.

--- TeX said ---
\u-default-954 #1->\textkappa 

Using utf8 I get:

ERROR: Package inputenc Error: Unicode char \u8:π not set up for use with LaTeX.

And I need characters more exotic than pi or kappa - like latin small letter long s e.g.

Stefan Kottwitz
  • 231,401
user17106
  • 907
  • 1
    There's little hope to get different sets of characters in this way: LaTeX fonts have only 256 characters. – egreg Aug 26 '12 at 20:48
  • And couldn't you use \pi instead of π, and similarly for the other symbols? You can do a Find&Replace in any good text editor. – yo' Aug 26 '12 at 21:06
  • @tohecz yes, but \pi doesn't work in verbatim environments, and there are quite a lot a rare characters for which I don't know the macro name (e.g. latin small letter long s). – user17106 Aug 26 '12 at 21:22
  • @egreg Not sure if I understand you - must I change the font or the way/approach? I tried e.g. \usepackage{ucs} and then \unichar{"17F}, but all I got was a black square in the pdf instead of the infamous latin small letter long s. – user17106 Aug 26 '12 at 21:26
  • 1
    @user17106 Couldn't you use some "cleverer" environment than verbatim? E.g. alltt or listings? (Disclaimer: I don't say that verbatim is wrong, but it simply does not interpret anything, and allowing the commands to be interpreted is one of the ways IMHO.) – yo' Aug 27 '12 at 06:05
  • @tohecz I already use wideverbatim, a customized verbatim, and its really essential for the book - can't change that. It would be already quite helpful if I find a way to have pdfLatex print these utf8 characters in normal text (outside verbatim). – user17106 Aug 27 '12 at 10:15
  • Sorry, but it's 2012: Use LuaLaTeX or XeLaTeX. Both engines can handle Unicode natively. – Martin Schröder Sep 02 '12 at 13:57
  • 1
    @MartinSchröder Did you try it out before flaming? I was surprised how poorly LuaLaTeX handles this example. The main problem is that lmodern does not contain upright Greek characters or the long s. In any case, http://tex.stackexchange.com/questions/65141/getting-started-with-greek-and-hebrew-in-lualatex might help to point you in the right direction since I agree that without LuaLaTeX you're pretty sure to be screwed. As for verbatim unicode ... boy, good luck with that. – Christian Sep 06 '12 at 23:46
  • @Christian: It is 2012 already, you don’t have to stick to the default font anymore. – خالد حسني Sep 08 '12 at 15:24
  • @KhaledHosny What is it with 2012 that you guys keep pointing it out over and over? The question explicitly asked for lmodern and Martin Schröder made it sound as if you just have to change to LuaLaTeX and everything will be fine. It isn't. Not even a warning is issued BTW that some characters couldn't be printed. – Christian Sep 09 '12 at 07:37
  • I tried the second solution, because looks shorter. I found that can't be used with utf8 input encoding. Must be used utf8x. – djnavas Sep 09 '12 at 05:37

2 Answers2

5

I was able to compile properly your MWE (although simplified a bit) using the textalpha package instead of textgreek. Here is how :

\documentclass{article}
\usepackage[utf8x]{inputenc} % Note : option utf8 works also
\usepackage[T1]{fontenc}
\usepackage{textalpha}

\begin{document}
\begin{verbatim}
   # sin(π * t)
\end{verbatim}
Kudos (κῦδος)
\end{document}

So I obtain the following result :

after compiling

(Added:) Please note that the textalpha package seems to give better results than the textgreek one.

rcabane
  • 339
  • Sorry, I only had one bounty and one 'answered' choice, but after downloading two packages I could make your solution work too, and its to simple. Thanks. – user17106 Sep 08 '12 at 10:29
4

The long s (ſ) is accessible through the TS1 fontencoding.
Depending on the frequency you need it in your text, you can use it

  • with the \longs command or
  • the "s command.

For written Greek text I'd use the babel package.
For Greek text in verbatim mode you can use the alltt package and either the babel package again or (for single letters) the textgreek package.
Edit: I just read that you use a customized wideverbatim environment. Can you provide a definition? I coudn't find one.

I have troubles with the Greek font encoding LGR.
Someone with a better understanding of font encoding might improve this answer.

\documentclass[graybox,envcountchap,sectrefs]{svmono}

\usepackage[LGR,TS1,T1]{fontenc}
\usepackage[utf8x]{inputenc}

\usepackage{lmodern}
\usepackage[polutonikogreek,english]{babel}
\usepackage{textgreek}
\usepackage{alltt}

\def\longs{{\fontencoding{TS1}\selectfont s}}
\def\greek#1{{\selectlanguage{greek}\fontencoding{LGR}\selectfont #1}}

\catcode`\"=\active%
\def"s{{\fontencoding{TS1}\selectfont s}}
\def\noLongS{\catcode`\"=12}

\begin{document}

\begin{alltt}
   # sin(\textpi * t)
   # sin(\greek{p} * t)
\end{alltt}

\noindent Kudos ({\greek{k~udos}) % κῦδος
\\
long s: Wach\longs tube\\
long s: Wach"stube\\
{\noLongS%
not a long s: Wach"stube}
\end{document}
David Carlisle
  • 757,742
Qrrbrbirlbel
  • 119,821