Try this. I created a command for mathpazo
U as well, because it's easier to see the difference.
\documentclass{article}
\DeclareSymbolFont{pazoletters}{OML}{zplm}{m}{it}
\DeclareMathSymbol{\pazoT}{\mathalpha}{pazoletters}{"54}
\DeclareMathSymbol{\pazoU}{\mathalpha}{pazoletters}{"55}
\begin{document}
$U \pazoU$ $T \pazoT$
\end{document}
Your third version \ieC
produces larger spacing since you have .
in text mode, i.e., the period ends a sentence. Usually one would probably write i.e.\ $x<2$
, which corresponds to your first version \ieA
. But it's up to you what you choose. Maybe in display math you'll prefer the larger spacing.
As for your second question, your \etc
doesn't work because it lacks \expandafter
. You test the next character with \@ifnextchar
, but have a look at your code: When in math mode, you test the \else
, and else you test the \fi
! I know, this is the point where programming TeX can drive you crazy. What you have to do: use \expandafter
to get rid of \else
and \fi
so that the \@ifnextchar
can actually see the next character.
Just as a side note: you should put some space between a \ne 0,
and b \ne 0
. Moreover, your code really contains a lot of %
s that could be omitted. Here's my solution for \etc
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xspace}
\makeatletter
\newcommand*{\textetc}{%
\@ifnextchar{.}
{etc}
{etc.\@\xspace}%
}
\newcommand*{\mathetc}{%
\@ifnextchar{.}
{\text{etc}}
{\text{etc.}}%
}
\makeatother
\newcommand*{\etc}{%
\ifmmode
\expandafter\mathetc
\else
\expandafter\textetc
\fi
}
\begin{document}\noindent
$a \ne 0,\ b \ne 0,\ \etc$\par\noindent
$a \ne 0,\ b \ne 0,\ \etc.$\par\noindent
\medskip\noindent
$a \ne 0,\ b \ne 0,\ \text{\etc}$ \quad \verb|\text{\etc}|\par\noindent
$a \ne 0,\ b \ne 0,\ \text{\etc.}$ \quad \verb|\text{\etc.}|\par\noindent
\bigskip
\noindent
Outside of math mode \verb|\etc| works now at the end of sentences!
\noindent
You should eat more fruit, i.e.\ apples, bananas, \etc. Next sentence.
\noindent
You should eat more fruit, i.e., apples, bananas, \etc but also tomatoes.
\end{document}
Best Answer
Done here with stacks. I added a descender to the mix, to make sure that the under-strut did not interfere. The strut/rule parameters are adjustable.
\rldp
is the vertical underset of the horizontal bar,\rlht
are the heights of the vertical struts, and\rlwd
is the rule thickness.Since the answer was accepted, I am EDITING it to provide a fuller explanation of what is done here. As to how the syntax of the stacking commands works, obviously reading the manual would be best. But short of that, in a nutshell, alignments are
r
right,c
center, andl
left (the default isc
). AnS
or short stack places two items vertically with a specified gap between the items, whereas aL
long stack places two items vertically with a specified distance between the baselines of the two items. The optional argument to\stackunder
is that stacking gap (short or long, depending on type). When stacks are nested (\stackunder{...\stackunder{}{}...}{}
), it is easiest to work from the inside out in trying to decipher it.For example, in
\uvbarR
, which creates the left side of the object, the inner\stackunder
places the centrally aligned vertical rule under the leading letter, the bottom of which is placed a distance\rldp
below the baseline of that letter (a long stack). The outer\stackunder
takes that stacked object, and places the right-aligned chunk of horizontal rule under it, the rule being only 1/2 the letter width. It places it with a negative vertical gap (overlap) of the rule width (short stack), so that finite rule-width lines lay flush.The other, perhaps, non-obvious facet of the solution is
\setbox0\hbox{${}#1{}$}
which was used to typeset the central portion (2nd argument of\ubar
) into a non-printed box. I did this only so that I could measure that box width (\wd0
) so that I knew how long to make the horizontal underbar. The{}
on either side of the argument (${}#1{}$
) says to math mode to typeset the leading and trailing\cdots
of the 2nd argument as if they have something else to their left and to their right (which of course, they do).EDITED to allow for label content to be wider than spread of under-bracket.