1

In my TeX document, I have my equations all pushed to the left instead of appearing in the center and I have it set so the output is a single "sheet" cropped to the output. The code for it is this:

\documentclass[varwidth=true, border=10pt]{standalone}
…
\begin{document}

\begin{flushleft}
% Equations go here.
\end{flushleft}

\end{document}

I want to get an equation to look like this:

f(x) = k * (x + c) + z
     = k * x + k * c + z

I'd like the lines that come after the first one to be aligned to the equal sign in the first and I want to keep it all in $…$. I can do that in OpenOffice using %phantom{}, but I don't know how to do that with LaTeX.

  • Are you looking for the fleqn option? – user121799 Mar 22 '18 at 18:43
  • @marmot I have no idea what that is. – Melab Mar 22 '18 at 18:46
  • \documentclass[fleqn, ...]{article}. – GuM Mar 22 '18 at 18:47
  • May I ask why you insist on placing the formulae inside $...$? – GuM Mar 22 '18 at 18:58
  • @GuM I want to keep it inbetween a pair of dollar signs because that makes it easy to distinguish math formatting from non-math formatting in the source code. – Melab Mar 22 '18 at 19:07
1

This is too long for a comment. Just add the fleqn option to your document.

\documentclass[fleqn]{article} 
\usepackage{amsmath}
\begin{document}
Bla bla bla
\begin{align}
f(x) &= k * (x + c) + z \notag\\
       &= k * x + k * c + z
\end{align}    
bla bla bla
\end{document}

enter image description here

  • I want to keep it in a $…$. – Melab Mar 22 '18 at 18:50
  • @Melab what is "it" and did you notice that align is a math environment, which, as the name suggests, aligns lines of equations? (That is, everything inside an align environment is in math mode.) – user121799 Mar 22 '18 at 18:52
  • "It" refers to the whole equation and I want to keep it inbetween a pair of dollar signs because that makes it easy to distinguish math formatting from non-math formatting in the source code. – Melab Mar 22 '18 at 19:06
  • 1
    @Melab But there is no need for that. Putting something between $ signs just means you put the stuff in math mode. The align environment also does that. – user121799 Mar 22 '18 at 19:09
  • 1
    @marmot -- i think this would more suitably be handled with equation and split since it has only one equation number. and really, the op needs to read some basic amsmath documentation. – barbara beeton Mar 22 '18 at 19:34
1

You can still use \phantom inside math mode:

enter image description here

\documentclass{article}

\setlength{\parindent}{0pt}% Remove paragraph indentation
\begin{document}

\begin{flushleft}
$f(x) = k \times (x + c) + z$

$\phantom{f(x) =} = k \times x + k \times c + z$
\end{flushleft}

$
\begin{array}{ @{} r @{} l @{} }
  f(x) = {} & k \times (x + c) + z \\
            & = k \times x + k \times c + z
\end{array}
$

\end{document}

Alternatively, alignment is also possible if you place content inside an array (second option provided above).

  • Can I use \phantom{} inside the same pair of dollar signs after a double backslash? – Melab Mar 22 '18 at 19:10
  • @Melab: Inside array? Yup. – Werner Mar 22 '18 at 19:14

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.