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.
If using either XeLaTeX or LuaLaTeX is an option for you, you may want to use the Cambria Math
font.
The following table contrasts the looks of w
and \omega
, as well as looks of the notoriously-similar triple v
, \upsilon
, and \nu
. Clearly, w
and \omega
are very different if Cambria Math
is loaded. Pagella, a Palatino clone, arguably does a credible job as well distinguishting these two characters. (If you must use v
, \upsilon
, and \nu
in one document, Pagella is your best bet. My recommendation, though, is simply not to use \upsilon
.)
If you decide to go with the Palatino clone, you could use it under pdfLaTeX by loading the packages newpxtext
and newpxmath
.
% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{unicode-math}
\begin{document}
\begin{tabular}{llll}
Latin Modern Math &
\setmathfont{LM Math} $ w\, \omega$
& $v\,\upsilon\,\nu$ & $\alpha\beta\gamma\delta$\\
Cambria Math &
\setmathfont{Cambria Math} $ w\, \omega$ & $v\,\upsilon\,\nu$ & $\alpha\beta\gamma\delta$\\
XITS Math &
\setmathfont{XITS Math} $ w\, \omega$
& $v\,\upsilon\,\nu$ & $\alpha\beta\gamma\delta$\\
TeX Gyre Pagella Math &
\setmathfont{TeX Gyre Pagella Math} $ w\, \omega$
& $v\,\upsilon\,\nu$ & $\alpha\beta\gamma\delta$\\
\end{tabular}
\end{document}
Best Answer
Just change the
\mathcode
ofv
:Output with the
\AtBeginDocument
line commented outOutput with the
\AtBeginDocument
line uncommentedComments
I'd suggest using
instead of
\usepackage{txfonts}
. The fonts are essentially the same, but the defects oftxfonts
are straightened off.