5

I'm looking for a way to move text in my equation, instead of just shoving multiple ~~~~ until it's in the right position. I'm quite new to LaTeX, what exactly would be the command?

I'm also looking for a way such that this command won't move the position of anything anything before it, but of course moves forward everything in front.

Right now I have:

\begin{equation*}
\begin{aligned}
\frac{\partial \Psi}{\partial x} &= 0     \mbox{ for } 0 \leq y \leq b \\
\frac{\partial \Psi}{\partial y} &= 0     \mbox{ for } 0 \leq x \leq a \\
\end{aligned}
\end{equation*}

I'm trying to increase the distance between the end of the fraction and the start of the text "for".

  • 3
    Welcome to TeX.SE! Have you tried \quad and/or \qquad to create the desired gap? – Mico Apr 20 '14 at 21:20
  • 1
    using \text{...} instead of \mbox{...} is recommended. – barbara beeton Apr 21 '14 at 5:17
3

Instead of using nested equation* and aligned environments, you could use a single align* environment. Two additional suggesions: (i) for the separation between the equation and condition parts, you could employ \qquad ("double \quad"); (ii) for a bit more vertical separation between the two rows, you could [1ex] immediately after the first \\ line break instruction.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\frac{\partial \Psi}{\partial x} &= 0 \qquad\text{for $0 \leq y \leq b$} \\[1ex]
\frac{\partial \Psi}{\partial y} &= 0 \qquad\text{for $0 \leq x \leq a$} \\
\end{align*}
\end{document}
  • 1
    better to use && before the \text just in case what is on the right-hand side of the = signs isn't always the same width. – barbara beeton Apr 21 '14 at 6:05
  • @barbarabeeton - Good point. I guess I was working with what the OP stated he/she wants to get typeset... – Mico Apr 21 '14 at 6:14
2

If you don't want the equations numbered (since you are using aligned), just adding a && after the = 0 on each row will insert a \quad = 1em horizontal gap between the equation and what follows AND left-align the following content (a single & would also add the 1em gap, but right-align what follows). The aligned type environments are aligned rlrlrl..., with a 1em gap after each left-aligned field.

An alternative method is also shown here, with a TABstack, in which the horizontal and vertical gaps between the equation parts may be independently specified.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabstackengine}
\stackMath
\begin{document}
Original
\begin{equation*}
\begin{aligned}
\frac{\partial \Psi}{\partial x} &= 0     \mbox{ for } 0 \leq y \leq b \\
\frac{\partial \Psi}{\partial y} &= 0     \mbox{ for } 0 \leq x \leq a \\
\end{aligned}
\end{equation*}
Extra alignment tab in aligned environment
\begin{equation*}
\begin{aligned}
\frac{\partial \Psi}{\partial x} &= 0&&     \mbox{ for } 0 \leq y \leq b \\
\frac{\partial \Psi}{\partial y} &= 0&&     \mbox{ for } 0 \leq x \leq a \\
\end{aligned}
\end{equation*}
a tabstack with vertical and horizontal gap size set
\setstackaligngap{3em}
\setstackgap{S}{8pt}
\begin{equation*}
\alignShortstack{
\dfrac{\partial \Psi}{\partial x} &= 0 &&\mbox{ for } 0 \leq y \leq b \\
\dfrac{\partial \Psi}{\partial y} &= 0 &&\mbox{ for } 0 \leq x \leq a \\
}
\end{equation*}
\end{document}

enter image description here

Other alternatives for horizontal space in equations, when tab alignment is not the appropriate method, can be accomplished either with \hspace{length}, with \kern length, or with \mkern mu-length. Additionally, as was pointed out in the comments, \quad and \qquad also insert "typical" (recommended?) math separations. With \hspace, inserted glue can be a factor (though I don't know if that is relevant in math mode), whereas no glue will be inserted about kerns.

0

The alignat environment can do what you want. Here are two suggestions — the second one requires using the mathtools package, which loads amsmath anyway:

\documentclass{article}

 \usepackage{mathtools}

 \begin{document}

\noindent A first solution:
\begin{alignat}{2}
\frac{\partial \Psi}{\partial x} &= 0 & \hspace{4em} & \mbox{ for } 0 \leq y \leq b \\
\frac{\partial \Psi}{\partial y} &= 0  &  &  \mbox{ for } 0 \leq x \leq a + 1
\end{alignat}
Or even,  keeping the first column centred:
\begin{alignat}{2}
\frac{\partial \Psi}{\partial x} &= 0 & \hspace{4em} & \mathrlap{\mbox{ for } 0 \leq y \leq b} \\
\frac{\partial \Psi}{\partial y} &= 0  &  & \mathrlap{\mbox{ for } 0 \leq x \leq a  + 1}
\end{alignat}
 \end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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