Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The Problem

When I use \Cline to underline a symbol in my equation, it increases the font size of that symbol. Edit: I don't want this to happen, rather, I would like all of my subscripts to be the same size, regardless of whether they are underlined or not.

Minimum Working Example

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}
\newsavebox\MBox
\newcommand\Cline[2][red]{{\sbox\MBox{$#2$}%
\rlap{\usebox\MBox}\color{#1}\rule[-1.2\dp\MBox]{\wd\MBox}{0.85pt}}}

\begin{document}
\begin{equation}    
\bar{\nabla}_{\!\mu}h_{\Cline{\rho\sigma}}
\end{equation}    
\end{document}

Edit - Follow-up Question: The Cherry on the Cake

Would it be possible to achieve the right-hand-side of the following image?

enter image description here

At the moment, egreg's code (see below) will give the left-hand-side output for the code

\begin{equation}
\bar{R}_{\tau\Cline{\sigma}\nu\Cline{\rho}}
\end{equation}

This is a marked improvement on the look to the output of the MWE above. However, I think it looks nicer if all the Cline lines are 'at the same level to the eye'.

share|improve this question
1  
You're basically using a construction with \mbox that uses by default the main text font size. –  egreg Feb 1 '13 at 13:37
    
Pardon me, I forgot to ask the actual question, which is "how can I change the font size of the underlined symbol to match that of the other subscripts?" –  User 17670 Feb 1 '13 at 13:42
1  
For the "cherry" problem you need to say \Cline{\vphantom{\rho}\sigma}. I'm not sure if the result is really better. –  egreg Feb 2 '13 at 13:36
add comment

1 Answer

up vote 10 down vote accepted

You can exploit \text that will do the right font size selection:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}
\newsavebox\MBox
\newcommand\Cline[2][red]{%
  \text{% We use \text so the size will be the right one
        \sbox\MBox{$#2$}% We typeset the argument
        \rlap{\color{#1}\rule[-\dimexpr\dp\MBox+1pt\relax]{\wd\MBox}{0.85pt}}% the rule
        \usebox{\MBox}% the text
        }% end of \text
}

\begin{document}
\begin{equation}
\bar{\nabla}_{\!\mu}h_{\Cline{\rho\sigma}}
\end{equation}
\end{document}

By setting the depth of the rule with \dimexpr we can be sure that the text will not be overwritten, because there will be 0.15pt between the text and the rule.

enter image description here


A different implementation without doing any measurement:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}

\newcommand{\Cline}[2][red]{%
  \text{%                
    \oalign{$#2$\cr\color{#1}\leaders\hrule height 0.85pt\hfil\cr}%
  }%
}

\begin{document}
\begin{equation}
\bar{\nabla}_{\!\mu}h_{\Cline{\rho\sigma}}
\end{equation}
\end{document}

You can adjust the vertical spacing between text and rule by adding a suitable

\noalign{\vskip-??pt}

(where ?? is some number) just after the first \cr.

enter image description here


Using a fixed rule thickness can be viewed as wrong; so here's a different specification:

\newcommand{\Cline}[2][red]{%
  \text{%
    \oalign{$#2$\cr\color{#1}\leaders\hrule height 0.2ex\hfil\cr}%
  }%
}

At 10pt size, 0.2ex is 0.86pt, so this is the same as your setting; but this will be slightly less in subscripts; with

\begin{equation}
\bar{\nabla}_{\!\mu}h_{\Cline{\sigma}}\Cline{aaa}
\end{equation}

we would get the preferable1 output

enter image description here

1 Thanks to David Carlisle for insisting in recommending this variable thickness as preferable.

share|improve this answer
    
ah I was all ready to post a \mathpallete version as well:-( shouldn't that .85pt be .085em (which is a bit easier using \text than using \mathpallete as the em size will change) –  David Carlisle Feb 1 '13 at 13:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.