TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up a system of equations and want to underline the last equation, but can't figure it out. Here's what I have:

&F_n &- mg &- F_a\sin 32^\circ &= 0\\
-&\mu F_n & &+ F_a\cos 32^\circ &= 0\\

After this I want line, and then the answer. I tried \underline, but that gave me errors. I also tried using \line, but that would give errors in the block or be too far away from the equations outside of the block.

Any help would be greatly appreciated!

share|improve this question
up vote 6 down vote accepted
&F_n &{}- mg &- F_a\sin 32^\circ &= 0\\
-&\mu F_n & &+ F_a\cos 32^\circ &= 0\\[-25pt]

enter image description here

share|improve this answer
Much more simpler than mine: +1. :) – Claudio Fiandrino Oct 24 '12 at 15:40
Possibly add {} before -mg to get the spacing right. – egreg Oct 24 '12 at 16:13
@egreg: Thank you. And added. :-) – Harish Kumar Oct 24 '12 at 16:21

This is a job for the \tikzmark macro if I interpreted correctly the request. The beauty of such an approach is that the rule underlying the equation fit exactly the dimensions of the equation.



% to change colors

%% code by Andrew Stacey 
% http://tex.stackexchange.com/questions/51582/background-coloring-with-overlay-specification-in-algorithm2e-beamer-package#51582

     remember picture with id/.style={%
       remember picture,
       save picture id=#1,
     save picture id/.code={%
     if picture id/.code args={#1#2#3}{%

  \expandafter\gdef\csname save@pt@#1\endcsname{#2}%


  \pgfsys@getposition{\csname save@pt@\tmk@label\endcsname}\save@orig@pic%
  \advance\pgf@x by -\pgf@xa
  \advance\pgf@y by -\pgf@ya

      \tikz[remember picture,overlay,baseline=1ex]
      \draw[line width=1pt,#1]
      (pic cs:#2) -- (0,0)

\tikz[remember picture with id=#2,baseline=1ex] #1;}

&F_n &- mg &- F_a\sin 32^\circ &= 0\\
\tikzmarkin[red]{a}-&\mu F_n & &+ F_a\cos 32^\circ &= 0\tikzmarkend{a}\\
& F_n &- mg &- F_a\sin 32^\circ &= 0\\
Here is my answer. Last equation is not needed, but it is a test to see where it will be placed with respect to the underlying line.

&F_n &- mg &- F_a\sin 32^\circ &= 0+a+b+c\\
\tikzmarkin[blue, line width=2pt]{b}-&\mu F_n & &+ F_a\cos 32^\circ &= 0+a+b+c\tikzmarkend{b}\\



enter image description here

It is based on the improved version by Andrew Stacey with a bit modification to just draw a line in which it's possible to customize the aspect.

Usage: \tikzmarkin{identifier} in the starting point, \tikzmarkend{identifier} in the ending point in which you have to draw the line. Optional argument for aspect just in \tikzmarkin: \tikzmarkin[blue, line width=2pt]{b}.

Notice that you should compile twice the document to get the right result (first run to set marker positions, second one to effectively draw the line). Last remark: the mark identifiers should be univoque in the document.

share|improve this answer

Your Answer


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.