For the underscore it's quite easy:
\documentclass{article}
\usepackage[T1]{fontenc}
\catcode`_=12
\begingroup\lccode`~=`_\lowercase{\endgroup\let~\sb}
\mathcode`_="8000
\begin{document}
Under_score but $a_{x}$
\end{document}
Actually the line \mathcode`_="8000
is redundant, but repeating it makes our intentions clear.
We make the character _
is "math active", i.e., it behaves like a macro, but only in math mode. The \begingroup\lccode...
trick defines this macro to be equivalent to \sb
which in turn is equivalent to the usual _
for introducing a subscript. In order that it's really seen as a math active character, we need to give it category code 12, which also makes it printable (outside math mode). However, we need a font that has an underscore in the right position, so we load the T1 output encoding.
Other special characters have to be treated in different ways. For example, the $
symbol can be "neutralized" by saying
\usepackage{fixltx2e}
\catcode`$=12
in the preamble; the package is necessary because it "robustifies" the \(
and \)
commands. In-line formulas must now be input with these commands, of course.
For the &
, one can say
\def\AM{&}
\catcode`&=12
and use \AM
for marking alignment points in tabular environments.
Also the #
character can be neutralized, as long as after saying
\catcode`#=12
one doesn't try defining new commands.
However, I don't recommend to change catcodes (other than the underscore, perhaps). A "search and replace", in case of a conversion to other formats, is safer.
I agree with the guys in the other forums - the issue is likely that the text file is in the wrong encoding - but I disagree with their solution. Depending on your operative system, I'll suggest two different solutions:
Under Linux
First a disclaimer: I use Ubuntu, and the exact commands might be slightly different under other distributions. The general idea is the same, however, so you should be able to iron out any cranks with the help of Google...
Confirming the diagnosis
To confirm that encoding is in fact the issue, cd
to the folder where your files reside, and do
$ file *
That should give you an output like the following (etc for more files):
example.tex: LaTeX 2e document, UTF-8 text
input.txt: ISO-8859 text
If the text file is listed as ISO-8859
(or something similar), or in fact anything other than "UTF-8 text", then encoding is your problem.
Fixing the problem
To convert ISO-8859 (a.k.a. "Latin 1") to UTF-8, you can use the following command
$ iconv -f latin1 -t utf8 input.txt > input.utf8.txt
iconv
is an encoding conversion utility. -f latin1
and -t utf8
are arguments to iconv
that tell the program which encoding the file is currently in, and which encoding you want it in. For a complete list of possible encoding names, do iconv --list
. The last argument is the file name of the input file (i.e. the one in the "wrong" encoding). iconv
writes the file, in the new encoding, to stdout
, so we redirect the output into a new file (don't use the same file name - you'll overwrite your file with an empty one).
Under Windows
Confirming the diagnosis
My standard way of confirming encoding problems under windows is to open the file in Notepad and select Save as...
- then there's a little dropdownlist that lets you choose the encoding of the file - if you don't change it, it states the current encoding of the file. Usually, files that I find problematic when using UTF-8 turn out to be saved in ANSI, which is Microsoft's own encoding (and quite similar to ASCII).
If encoding is your problem, this dropdownlist shows something other than "UTF-8".
Fixing the problem
To fix it, simply select UTF-8 in the dropdownlist, (optionally) select a new file name for your input file, and hit Save.
Notepad converts the file intelligently, but if you experience problems you can (usually) simply reverse the process to get back the file you started with, and try something else.
Best Answer
FF Seria Pro [Is this the correct font?] seems to not have the glyph
ḥ
:Neither the online preview shows it, nor does it appear on one of the three pages of the “complete character set”.
Possible solutions:
ḥ
from another font that is as close to Seria Pro as possible. (Bad)You mimick it (build it yourself).
With the help of the
calc
you could do:Or, of course, make it your own macro:
Or, if you want to use the original char
ḥ
(it's XeLaTeX after all), make it active:You may adjust the dimension
-.45ex
so that it looks good.You use another font.
This may be the best choice if you need to typeset a lot of those “funny” characters that don't exist in the chosen font!
If you need a lot of “under-dotted” characters you might even want to redefine the existing
\d
macro to