5

How can I make comments inside an long equation, something like:

\begin{equation}
G(r) 
% comment here
= \frac{A}{B} 
= \frac{\frac{t_c}{3}}{2 \cdot \frac{2t_b + t_v + t_c}{r}}  = \frac{t_c}{6 \cdot (2t_b + t_v + t_c)} \cdot r
\end{equation}
  • 1
    Do you mean insert some explanatory text in the typeset output or in the source code? You may be looking for \text{..} or \intertext{..} used in conjunction with the align environment? – Bordaigorl Jul 06 '15 at 09:43
  • If you mean a code comment, that is only visible inside your .tex-file and is ignored by the compiler, it should just work the way, you did it: put a %-sign infront of your comment. – Wamseln Jul 06 '15 at 09:55
  • 1
    @SparkandShine: Not sure of what you want, but you might be interested to my answer to this question asking how to add short explanations-notes-comments to an equation with alignment points. – Bernard Jul 06 '15 at 11:56

2 Answers2

6

Do you mean something like this? If you are referring to setting source code (LaTeX listings) you should clarify that a bit in your question.

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{align}
    G(r) & \\
\shortintertext{comment}
    &= \frac{A}{B} \\
    \intertext{a long comment could look like this}
    &= \frac{\frac{t_c}{3}}{ 2 \cdot \frac{2t_b + t_v + t_c}{r}}  = \frac{t_c}{6 \cdot (2t_b + t_v + t_c)} \cdot r
\end{align}
\end{document}

enter image description here

LaRiFaRi
  • 43,807
5

Just to provide a few more ideas:

  • \shortintertext{} which needs mathtools is my personal favourite and there's already an example
  • \intertext{} is similar to \shortintertext{} but will have a larger space above and below the the math, also in the example
  • \tag{} is different as it will put text in brackets at the end of the line of Math. If the tag text cannot fit into the line, it will be placed on the line below

Note that some of these, I forget which, only work in AMS environment equations.

Hope it helps!

Alwin
  • 679