Special names in Latex
In my english thesis latex file, how to mention the following non English words: François, École Fédérale?
Thanks and reg开发者_运维百科ards!
The traditional way is to use the accent-adding macros:
Fran\c{c}ois
\'Ecole F\'ed\'erale
(You can also write Fran\c{}cois
or Fran\c cois
; the \c
macro uses no parameter; the braces or space are just a trick to allow LaTeX to see the proper macro name.)
Otherwise, try this:
\usepackage[utf8]{inputenc}
and type the accents directly, with UTF-8 encoding.
There are a host of more-or-less subtle issues with fonts and hyphenation.
If you don't go the UTF8 inputenc route, and yet find yourself writing a lot of these names, I'd suggest defining macros for them. At the simplest, you can say
\newcommand\Francois{Fran\c cois}but then you need to be sure to use it as such:
\Francois{}
so that any spaces afterwards don't get gobbled.
On the other hand, the following technique works pretty well too (though I can't take credit for inventing it - I saw it originally in a short talk at BachoTeX 2009 by Philip Taylor):
\makeatletter \let\latex@less< \catcode`<13 \def<{\ifmmode\latex@less\else\expandafter\find@name\fi} \def\find@name#1>{\@nameuse{name.#1}} \def\DefineName#1#2{\@namedef{name.#1}{#2}} \makeatother
Now you can define special names using, e.g.
\DefineName{Francois}{Fran\c cois} \DefineName{Ecole Federale}{\'Ecole F\'ed\'erale}
and later on you can use them in text with
I ran into <Francois> at the <Ecole Federale> the other day.
You can make your tags (the plain ASCII versions) be whatever you want - they don't have to actually be related to the properly accented names.
EDIT: in response to the issue that misspelled names don't produce errors, you can change the definition of
\find@name
to
\def\find@name#1>{\ifcsname name.#1\endcsname \@nameuse{name.#1}% \else \@latex@warning{Undefined name #1}% \fi}
Note that \@latex@warning{...}
can be changed to \@latex@error{...}\@eha
and it will complain more forcefully. Or if you want to pretend to be (or actually be) a package you can use \Package(Warning|Error){<package name>}
in place of \@latex@(warning|error)
and it won't pretend to be a built-in LaTeX error anymore.
精彩评论