[OS X TeX] Macintouch report on TeX versus Word

Peter Dyballa Peter_Dyballa at Web.DE
Sun Jan 25 01:14:10 CET 2009


Am 24.01.2009 um 03:26 schrieb Jason Davies:

> Finally -- people have mentioned switching to XeTeX. How easy is  
> that for someone who knows only some fairly basic LaTeX?


It's easy. On MS PCs you need to find a utility that gives you the  
font names, on Linux you need libfontconfig and the command line  
utilities fc-cache/fc-list/fc-match or use another application to  
retrieve font names, and on Mac OS X the Font Book application can  
give you the names. Then you just swap the LaTeX preamble with a  
XeLaTeX preamble (maybe you need to switch from babel to polyglossia,  
which I have not tried yet) and start to write and save in UTF-8. Or  
UTF-16. (Both are *text* encodings. The font encoding is simply named  
Unicode.) Ahh, there is a bug: XeTeX or the xdvipdfmx output driver  
do not follow the settings done with the geometry package,  
particularly in landscape or in non-letter or non-ISO A4 formats –  
or for books. Even Adobe products fall into this pit. There are  
differences in the way the PDF information fields are filled – if  
you want to do it with \special's; the consistent way is \hypersetup 
{}. Ah, before I forget: not all PSTricks work; maybe TikZ/PGF  
(beamer) too only works partly.

Here is the template of a preamble that works both for LaTeX  
(producing PDF or DVI, maybe the latter needs a bit more regard, but  
I gave it up so long ago…) and for XeLaTeX (correct my font choices,  
the usual suspects Times, Helvetica, & Courier can be OK):


%%!TEX TS-program=xelatex	-*- mode: LaTeX; coding: utf-8; -*-
%%!TEX encoding=UTF-8 Unicode
%
%	Time-stamp: <2009-01-25 01:07:18 pete>
%
\documentclass[a4paper,11pt]{article}
\usepackage{ifpdf,ifxetex,graphicx}
%\usepackage[ngerman]{babel}
\usepackage 
[landscape,nohead,ignoreheadfoot,right=3.75mm,bottom=12.5mm,top=8.75mm,n 
omarginpar,verbose]{geometry}
\usepackage[svgnames]{xcolor}
\def\author{Peter Dyballa}
\def\Schlagworte{LaTeX, XeLaTeX, UTF-8, geometry, hyperref}
\ifxetex
   \def\title{Wörtér mït Ümläûtèñ}				% Does not translate in  
pdfTeX!
   \def\Betreff{Ȟÿṗéṛŗèḟ ŧêşẗ ẘïťĥ  
ăčçëńṭṣ}			% Does not translate in pdfTeX!
\else
   \def\title{W\"ort\'er m\"it \"Uml\"a\^ut\`e\~n}
   \def\Betreff{H\"yp\'err\`ef t\^est w\'ith ac\c{c}\"e\'nts}	% OK  
for PDFDocEncoding, but not the next!
%  \def\Betreff{\v{H}\"y\.p\'e\d{r}\c{r}\`ef \b{t}\^e\c{s}\"t \r{w}\'i 
\v{t}\^h \u{a}\v{c}\c{c}\"e\'n\.t\.s}
\fi
%U\usepackage[unicode,colorlinks,breaklinks,bookmarks,
%U	pdfauthor={\author},pdftitle={\title},pdfsubject= 
{\Betreff},pdfkeywords={\Schlagworte}]{hyperref}
\usepackage[colorlinks,breaklinks,bookmarks,pdfauthor={\author},debug] 
{hyperref}
\pdfstringdef{\Titel}{\title}
\pdfstringdef{\Subjekt}{\Betreff}
\pdfstringdef{\Keywords}{\Schlagworte}
\hypersetup{
     pdftitle=\Titel,
     pdfsubject=\Subjekt,
     pdfkeywords=\Keywords
   }
\ifxetex
      \immediate\write16{==We're with XeTeX==}
   \usepackage[no-math]{fontspec}
   \usepackage{xltxtra,xunicode}
   \defaultfontfeatures{Mapping=tex-text}
%  \setmainfont{Lucida Bright}
   \setromanfont{Lucida Bright}
   \setsansfont{Lucida Sans}
   \setmonofont{Lucida Sans Typewriter}
%  \newfontface\textsl[RawFeature={slant=0.194}]{Lucida Bright}
%    \DeclareGraphicsExtensions{.pdf,.png,.jpeg,.bmp,.eps}		% formats  
with xdvipdfmx
%    \DeclareGraphicsExtensions{.mac,.pict,.psd,.sgi,.tga,.tif,.gif}	 
% additionally with xdv2pdf, less eps!
%    \special{pdf: docinfo <<
%	/Keywords	(\Schlagworte)
%	/Subject	(\Subjekt)
%       /Title		(\Titel)
%        >>}
\else
   \immediate\write16{==We're without XeTeX==}
   \ifpdf
     \immediate\write16{==\jobname: Bonjour, PDF!==}
     \usepackage{cmap}
%    \DeclareGraphicsExtensions{.pdf,.png,.jpeg}			% in pdfTeX  
allowed graphics formats
     \usepackage[activate={true,nocompatibility}]{microtype}
%    \usepackage[protrusion=true,expansion=true]{microtype}
     \usepackage{lucida}
     \makeatletter							% following code needs hyperref
     \@ifundefined{pdffilemoddate}{%
        \PackageError{sourcetime}{%
          pdfTeX >= 1.30.0 required%
        }%
        \let\pdffilemoddate\@gobble
     }{}%
     \newcommand*{\SourceFile}[1]{%
       \edef\@SourceFileDate{\pdffilemoddate{#1}}%
       % empty in case of errors, but don't harm in next comparison
       \ifnum\pdfstrcmp{\@SourceFileDate}{\@CurrentSourceFileDate}>0 %
         \let\@CurrentSourceFileDate\@SourceFileDate
         \expandafter\@ParseDate\@SourceFileDate\@nil
         \hypersetup{%
           pdfcreationdate={\@SourceFileDate},%
           pdfmoddate={\@SourceFileDate}%
         }%
         \PackageInfo{sourcetime}{%
           Using file `#1'%
         }%
       \fi
     }
     \newcommand*{\@CurrentSourceFileDate}{}
     \expandafter\def\expandafter\@ParseDate\detokenize{D:} 
#1#2#3#4#5#6#7#8{%
       \year=#1#2#3#4\relax
       \month=#5#6\relax
       \day=#7#8\relax
       \@ParseTime
     }
     \def\@ParseTime #1#2#3#4#5\@nil{%
       \time=\numexpr #1#2 * 60 + #3#4\relax
     }
     \makeatother
     \SourceFile{\jobname.tex}
%    \pdfinfo
%      {
%	/Title		(An UTF-8 LaTeX Example)
%	/Author		(Peter Dyballa)
%	/Subject	(ISO Latin-1 and ISO Latin-9 characters)
%	/Keywords	(LaTeX, UTF8, ISO, Latin-1, Latin-2, Latin-9, ISO 8859,  
LICR)
%    }
   \else
     \immediate\write16{==¡Hola \jobname: DVI!==}
%    \DeclareGraphicsExtensions{.ps,.eps}				% in dvips allowed  
graphics formats
     \usepackage[protrusion=true,expansion=false]{microtype}
     \usepackage{times}
   \fi
   \usepackage[utf8x]{inputenc}
%  \usepackage[utf8]{inputenc}
   \usepackage[full]{textcomp}
%  \usepackage[LUC,T1]{fontenc}
   \usepackage[T1]{fontenc}						% other font encodings: T2A, T2B,  
T2C, X2, LCY, OT2 (LY1, T5)
   %%%%\renewcommand{\sfdefault}{pag}
   %%%%\renewcommand{\rmdefault}{ppl}
   %%%%\renewcommand{\ttdefault}{pcr}
   \makeatletter
   \newcommand*\TeX at logo@spacing[6]{%
     \def\xxt at kern@Te{#1}%
     \def\xxt at kern@eX{#2}%
     \def\xxt at lower@e{#3}%
     \def\xxt at kern@La{#4}%
     \def\xxt at kern@aT{#5}%
     \def\xxt at kern@eL{#6}%
   }
   \DeclareRobustCommand\XeTeX{%						make a bit of XeTeX available  
outside ...
     \leavevmode
     \smash{%
       X\lower\xxt at lower@e
       \hbox{\kern\xxt at kern@eX
         \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0%
         \reflectbox{E}%
      }\kern\xxt at kern@Te\TeX}}%
   \DeclareRobustCommand\XeLaTeX{%
     \leavevmode
     \smash{%
       X\lower\xxt at lower@e
       \hbox{\kern\xxt at kern@eX
         \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0\relax
         \reflectbox{E}%
     }\kern\xxt at kern@eL\LaTeX}}
   \TeX at logo@spacing{-0.15em}{-0.125em}{0.5ex}{-0.36em}{-0.12em} 
{-0.13em}
   \makeatother
\fi

\begin{document}
Some example text ...
\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


--
Greetings

   Pete

Government is actually the worst failure of civilized man. There has  
never been a really good one, and even those that are most tolerable  
are arbitrary, cruel, grasping and unintelligent.
				– H. L. Mencken






More information about the macostex-archives mailing list