5

Using this code:

\begin{flalign}
& +3x+2y-5z=+04 \\
& +2x+4y-1z=+12 \\
& -4x-8y+9z=-06 &
\end{flalign}

I produce this output:

pre-output

However, I'd like to produce a similar alignment, but without leading 0's, 1's, and +'s.

I would like my code to produce this:

post-output

How do I modify my code to produce this?

5

Variant with \hphantom

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign}
& \mathbin{\hphantom{+}}3x+2y-5z=\hphantom{+0}4 \\
& \mathbin{\hphantom{+}}2x+4y-\hphantom{1}z=\hphantom{+}12 \\
& -4x-8y+9z=\hphantom{0}{-}6 &
\end{flalign}
\end{document}

Result \hphantom

  • The space after the = is a little too large, because the needed space is the maximum of two digits or one digit with sign instead of one sign with two digits. Since the sign is larger than a digit, the 1 of 12 is set via \llap.

  • Also, I do not think, the first sign in the line -4x should be spaced as binary operator, thus the following example uses an unary minus sign instead:

Example:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign}
& \hphantom{+}3x+2y-5z = \hphantom{+}4 \\
& \hphantom{+}2x+4y-\hphantom{1}z = \hphantom{+}\llap{$1$}2 \\
& {-}4x-8y+9z = {-}6 &
\end{flalign}
\end{document}

Result optimized \hphantom

4

As @vonbrand said, you can easily write systems of equations using systeme package, sadly for me the documentation is in french.

Code:

\documentclass{article}
\usepackage{systeme}

\begin{document}

\systeme{3x+2y-5z=4,2x+4y-z=12,-4x-8y+9z=-6}%Default settings

\medskip

\sysdelim{.}{.}\systeme{3x+2y-5z=4,2x+4y-z=12,-4x-8y+9z=-6}%Without the left brace

\medskip

\sysdelim{.}{.}\systeme{3x+2y-5z=4@E_{*},2x+4y-z=12,-4x-8y+9z=-6}%Equations with numbers

\end{document}

Output

enter image description here

UPDATE

This question shows you how to the change the alignment of the RHS of the equations in order to do that you just need to redefine the command \SYS@makesyspreamble@i as @egreg mentioned

UPDATE Code

\documentclass{article}
\usepackage{systeme}

\usepackage{regexpatch}

\makeatletter
\xpatchcmd{\SYS@makesyspreamble@i}
{$##$\hfil\null}% left alignment
{\hfil$##$\null}% right alignment
{}{}
\makeatother

\begin{document}

\systeme{3x+2y-5z=4,2x+4y-z=12,-4x-8y+9z=-6}

\medskip

\sysdelim{.}{.}\systeme{3x+2y-5z=4,2x+4y-z=12,-4x-8y+9z=-6}

\medskip

\sysdelim{.}{.}\systeme{3x+2y-5z=4@E_{*},2x+4y-z=12,-4x-8y+9z=-6}

\end{document}
  • 3
    The alignment of the RHS does not match what the OP requests. – Werner Sep 1 '15 at 1:47
0

The systeme package (in TeXlive and MikTeX) is geared towards this. Haven't used it, though.

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.