2

I have a very long equation in \align* environment so that I split it into two lines as shown in the screenshot blew

enter image description here

I want to write some text side to side the above part of the equation using &&\text{} ,but Latex throw it away in the margins and I do not know why this happens. Here is my code regarding this part :

\begin{align*}
X_{p}\psi &=  
X_p\bigl( \psi(p) \bigr) 
 + \sum_i \left(\left.\frac{\partial \psi}{\partial x^{i}}\right|_{p} \right) X_{p}\left(x^{i}-a^{i}\right)           &&\text{(plaplapla)} \\
&\phantom{{}= }+ \sum_i \sum_j X_{p}\left( \left(\zeta_{ij}\circ\phi \right)\left(x^{i}-a^{i}\right)\left(x^{j}-a^{j} \right) \right) .

The first & is using for aligning equations later, any my preamble just has the necessary packages for mathematics.

I appreciate any help. Thanks in advance.

5
  • I can't seem to reproduce the issue you're experiencing (...the text being pushed into the margin). Can you elaborate?
    – Werner
    Commented Dec 17, 2016 at 0:39
  • I’ve deleted my answer since I realized that it was a completely wrong solution for a nonexistent problem… :-)
    – GuM
    Commented Dec 17, 2016 at 1:19
  • Your code doesn't feature a &&\text{} portion. Please fix.
    – Mico
    Commented Dec 17, 2016 at 3:43
  • I fixed it @Mico Commented Dec 17, 2016 at 3:49
  • @HusseinEid: ...there still isn't any evidence that the text is "thrown away into the margin".
    – Werner
    Commented Dec 17, 2016 at 4:01

2 Answers 2

2

Assuming the explanatory text string isn't all that long, it should be enough to separate it from the other material in the first row with a \quad or \qquad directive.

I would also like to recommend strongly that you get rid of the habit of using \left and \right with all math-mode parentheses. See, e.g., Is it ever bad to use \left and \right? for more information on this subject.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\hrule % Just to illustrate the width of the text block -- feel free to omit!
\begin{align*}
X_{p}\psi &= X_p\bigl( \psi(p) \bigr) 
  +\sum_i \biggl(\frac{\partial\psi}{\partial x^{i}}\biggr|_{p}\,\biggr) X_{p}(x^{i}-a^{i}) 
  \qquad\text{some explanatory thoughts}\\
&\quad+ \sum_i \sum_j X_{p}\bigl( (\zeta_{ij}\circ\phi)(x^{i}-a^{i})(x^{j}-a^{j}) \bigr) .
\end{align*}
\end{document}
4

There are several possible solutions to this problem, depending both on the real equations and the real hints, and also on the page layout. It's easier if you load the geometry package, because the default horizontal margins with geometry are much more sensible. Second, you can use for the second line (without hint) the \mathrlap command from mathtools (which loads amsmath, so don't load the latter). alignat would let you control the horizontal spacing between equation and hints.

Here is an example:

\documentclass[a4paper,]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage[showframe]{geometry}%

\begin{document}

\begin{align*}
  X_{p}ψ&=
  X_p\bigl( ψ(p) \bigr)
  + ∑_i \left(\left.\frac{∂ ψ}{∂ xⁱ}\right|_{p} \right) X_{p}\left(xⁱ-aⁱ\right) &   & \text{some more or less long hint} \\
  &\phantom{{}= }+ ∑_i ∑_j \mathrlap{X_{p}\left( \left(\zeta_{ij} ∘ \phi \right)\left(xⁱ-aⁱ\right)\left(x^{j}-a^{j} \right) \right)+A+B.}
\end{align*}

\end{document} 

enter image description here

6
  • This solution is not preferable of course. It is horrible to show the frames. Is there an alternative solution ? Commented Dec 17, 2016 at 3:25
  • 2
    @HusseinEid - Have you looked at Bernard's code? Have you figured out what the showframe option does -- and that it's entirely possible to omit this option?
    – Mico
    Commented Dec 17, 2016 at 3:49
  • The only difference between this code and my code is the showframe option which creates a frame for every page. @Mico Commented Dec 17, 2016 at 3:51
  • @HusseinEid - Did you notice the & & \text{some more or less long hint} part? It's not in your posting...
    – Mico
    Commented Dec 17, 2016 at 3:52
  • 1
    It exists… now, not when I answered. More seriously, the real important different is the use of \mathrlap for the hint, which allows the hint column to overlap the end of the first column (to some extent. I've updated the code, changing the equation to make that more apparent. As to the showframeoption, it is there only to visualize the hint does not go into the margin.
    – Bernard
    Commented Dec 17, 2016 at 13:52

You must log in to answer this question.

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