4

Most of the times I use equations that have subscripts and sometimes I want to give a short explanation of the subscripts, e.g., what are the limits, or which are the categories, should they be small enough.

In this minimal example I do not like the placement of the subscript explanation (I have used \qquad) but it is still quite close to the main part. I would like it to be at the very end of the line.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[leqno]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\author{PSK}

\begin{document}
Some stuff ...

\begin{equation}
V_i = a_i + B_i \qquad (i = 1, \dots, N)
\end{equation}

\end{document}
2
  • \qquad is the standard amount of space to use here. Apr 3, 2014 at 15:28
  • @AndrewSwann can I make the subscript explanation right justified? I mean only this part, not the whole equation. Apr 3, 2014 at 15:30

2 Answers 2

1

I introduce \notateeqn{equation}{notation} to do the trick.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[leqno]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{stackengine}
\stackMath
\newcommand\notateeqn[2]{%
  \stackengine{0pt}{\displaystyle#1}{\makebox[\textwidth]{\hfill#2}}{O}{c}{F}{T}{L}%
}
\begin{document}
Some stuff ...
\begin{equation}
\notateeqn{V_i = a_i + B_i}{(i = 1, \dots, N)}
\end{equation}
\noindent\hrulefill
\end{document}

enter image description here


ADDENDUM

Trying to satisfy both egreg's strong recommendation, as well as trying to satisfy the OP's added request for a fixed equation indent, I show how my technique can be used to fix the indent of the equation by defining a new length \eqnindent, while still leaving room for a right-aligned notation. In this MWE, I use the notation space for things other than the (i =...) specifier (so as not to offend egreg's sensibilities). I set an artificial "ruler" just so one can confirm that the indent levels of .3, .2, and .5 of \textwidth are properly met.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[leqno]{amsmath}
\usepackage{amsfonts, amssymb, makeidx, graphicx, stackengine}
\newlength\eqnindent
\stackMath
\newcommand\notateeqn[2]{%
  \setbox0=\hbox{$\displaystyle#1$}%
  \hspace{\dimexpr2\eqnindent-\textwidth+\wd0\relax}%
  \stackengine{0pt}{\displaystyle#1}{\makebox[\textwidth-\eqnindent]{\hfill#2}}{O}{l}{F}{T}{L}%
}
\begin{document}
\setlength\eqnindent{.3\textwidth}
Setting indent to 0.3 textwidth
\begin{equation}
\notateeqn{V_i = a_i + B_i,\qquad(i = 1, \dots, N)}{(Notation)}
\end{equation}

Setting indent to 0.2 textwidth
\setlength\eqnindent{.2\textwidth}
\begin{equation}
\notateeqn{V_i = a_i + B_i}{(The Equation Name)}
\end{equation}

Setting indent to 0.5 textwidth
\setlength\eqnindent{.5\textwidth}
\begin{equation}
\notateeqn{V_i = a_i + B_i}{(My Notation)}
\end{equation}
\noindent$|$\hrulefill$\cdot$\hrulefill$|$\hrulefill$\cdot$\hrulefill$|$\hrulefill$\cdot$%
\noindent\hrulefill$|$\hrulefill$\cdot$\hrulefill$|$\hrulefill$\cdot$\hrulefill$|$
\end{document}

enter image description here

6
  • Thanks, this is a sublime solution. Another favour if possible. Can we have predetermined distance from the number, let us say 1.5cm, and the main equation? Apr 3, 2014 at 19:17
  • 1
    @PantelisKazakis You may like it, but it's not the way to go; a \qquad is just what you need. Really.
    – egreg
    Apr 3, 2014 at 22:14
  • @egreg Is there a specific reason for that? Is there a rule dictating that we should always used \qquad, and if so, why? Apr 4, 2014 at 15:01
  • 1
    @PantelisKazakis I have added an addendum to my answer. Is this the sort of thing you are looking for? Apr 4, 2014 at 15:51
  • 1
    @StevenB.Segletes what a superb LaTeX technician! Yes, this is what I am looking for! P.S. I fear that egreg does not approve though :) Apr 4, 2014 at 16:20
4

You can do that with the \flalign environment and mathtools (which loads amsmath): it has many enhancements to amsmath, corrects a couple of bugs, and of special interest in your case, defines a math version of \llap.

\documentclass[12pt,a5paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[leqno]{mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage[showframe, nomarginpar]{geometry}
\author{PSK}

\begin{document}
Some stuff ...

\begin{flalign}
 &  & V_i  &   = a_i + B_i   &  & \mathllap{(i = 1, \dots, N)}
\end{flalign}

\end{document} 

enter image description here

Of course, there's a chance that for a long equation, the explanation overlaps the end of the equation. In such a case, you can put the explanation on next line (unnumbered with \notag), but still at the end of the line.

3
  • 1
    +1 But the \mathllap is not necessary here and perhaps even not helpful, it allows the right text to overlap the equation in the middle. Apr 3, 2014 at 15:49
  • I was wondering if we can make it more neat. That is, the equation number to be let us say 1.5cm from the actual equation, this means that someone would not need the & all the time. And of course again the explanation should be at the very end. Apr 3, 2014 at 15:50
  • @Andrew Swann:the \mathllap, as I see it, is here for the centring of the main (middle group) equation: LaTeX places it as if there were no explanation. Of course the explanation must not be too long, or else it should be placed on next line. Anyway you can play with which part of the "explanation" is "llapped" so to say. For instance : \mathllap{1 \leq i,j \leq} m+1-k. Or, if it's a text explanation, use a smaller fontsize.
    – Bernard
    Apr 3, 2014 at 16:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .