3

I would like to write equations like this:

enter image description here

But with all the "x=" left aligned after the word "Soit" (meaning "either" in english). Here I used the following code with the \phantom{} command, which is far not the best and doesn't align exactly the "x=":

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}
\begin{document}
   \[
   \begin{array}{l|l}
       3x^4=48 \quad   &\cdot\dfrac{1}{3}\\
       x^4=16  &\\
       \mbox{Soit } x=\sqrt[4]{16} &\\
       \phantom{Soitt} x=2 &\in\mathcal{D}_x\\
       \mbox{Soit } x=-\sqrt[4]{16} &\\
       \phantom{Soitt } x=-2 &\in\mathcal{D}_x\\
   \end{array}
   \]  
\end{document}

I also tried the \multicolumn command, but then the vertical line after the \multicolumn command is shifted to the left, and it gives this:

enter image description here

with the following code:

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}
\begin{document}
    \[
    \begin{array}{ll|l}
        \multicolumn{2}{l|}{3x^4=48} \quad  &\cdot\dfrac{1}{3}\\
        \multicolumn{2}{l|}{x^4=16} &\\
        \mbox{Soit } &x=\sqrt[4]{16} &\\
        &x=2    &\in\mathcal{D}_x\\
        \mbox{Soit } &x=-\sqrt[4]{16} &\\
        &x=-2 &\in\mathcal{D}_x\\
    \end{array}
    \]  
\end{document}

Does anyone have a solution?

1
  • Please see my updated answer. Jul 24, 2022 at 16:10

3 Answers 3

2

In your (particular) case you can use simple array, and top and bottom aligned math environments:

\documentclass[12pt,a4paper]{book}
\usepackage[margin=2.50cm]{geometry}

\usepackage{array}
\usepackage{amsmath}


\begin{document}
\[
    \begin{array}{l|l}
\begin{aligned}[t]
3x^4 & = 48     \\
 x^4 & = 16 
 \end{aligned}  & \cdot\frac{1}{3}                           \\
 \begin{aligned}[b]
\mbox{Soit}\quad    x & = \sqrt[4]{16}      \\  
                  & = 2
\end{aligned}   & \in \mathcal{D}_x     \\
 \begin{aligned}[b]
\mbox{Soit}\quad   x & = -\sqrt[4]{16}    \\
                  & =- 2
\end{aligned}   & \in \mathcal{D}_x     \\
    \end{array}
\]
\end{document}

enter image description here

5

Here's the solution based on array. In order to achieve the effect beginning from the 3rd row, you can make "Soit" be a part of the first column and remove space it would normally occupy to avoid pushing the first = towards the right; this is done by \rlap{}. See the example:

enter image description here

\documentclass[12pt,a4paper]{book}
\usepackage{array}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}


\begin{document}
\[
    \begin{array}{r @{\;}c@{\;} r @{\;}c@{\;} l|l}
                                          3x^4 &=& 48 & &            & \displaystyle \frac{1}{3} \\
                                           x^4 &=& 16 & &            & \\
    \multicolumn{1}{l}{\rlap{Soit}} & &  x &=& \sqrt[4]{16}  & \\
                                               & &  x &=& 2          & \in \mathcal{D}_x \\
    \multicolumn{1}{l}{\rlap{Soit}} & &  x &=& -\sqrt[4]{16} & \\
                                               & &  x &=& -2         & \in \mathcal{D}_x
    \end{array}
\]
\end{document}
4

This is another variant with the equals signs aligned.

a

I used the nicematrix package with the cell-space-limits=4pt option to vertically expand the cells.

% !TeX TS-program = pdflatex

\documentclass[12pt,a4paper]{book}
\usepackage[T1]{fontenc}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}

\usepackage{nicematrix}% added <<<<<<<<<<

\begin{document}

\NiceMatrixOptions{cell-space-limits=4pt}% expand the cells vertically  
\setlength{\arraycolsep }{3pt}% control the columns separation


$\begin{NiceArray}{rcc|@{\;}cl}
3x^4            &=& 48              & &  \displaystyle \frac{1}{3} \\
x^4             &=& 16              & &                     \\
\text{Soit}\ x  &=& \sqrt[4]{16}    & &                     \\
x               &=& 2               & &  \in \mathcal{D}_x  \\
\text{Soit}\ x  &=& -\sqrt[4]{16}   & &                     \\
x               &=& -2              & &  \in \mathcal{D}_x  \\
\end{NiceArray}$

\end{document}

UPDATE Or with the first two equation left aligned and without additional packages:

c

% !TeX TS-program = pdflatex

\documentclass[12pt,a4paper]{book}
\usepackage[T1]{fontenc}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}

\begin{document}
    
  
    \setlength{\arraycolsep }{3pt}% control the columns separation  
    
    $\begin{array}{lcl|@{\;}cl}
        3x^4 =48        &   &                   & &  \cdot\displaystyle \frac{1}{3} \\
        x^4  =16        &   &                   & &                     \\
        \text{Soit}     &x =& \sqrt[4]{16}      & &                     \\
                        &x =& 2                 & &  \in \mathcal{D}_x  \\
        \text{Soit}     &x =& -\sqrt[4]{16}     & &                     \\
                        &x =& -2                & &  \in \mathcal{D}_x  \\
    \end{array}$
    
\end{document}

Finally, using your setup, to get the vertical line right add another column. Try this code:

\[
\begin{array}{lll|l}
    \multicolumn{2}{l}{3x^4=48}                     &   &\cdot\dfrac{1}{3}\\
    \multicolumn{2}{l}{x^4=16}                      &   &               \\
    \mbox{Soit }                &x=\sqrt[4]{16}     &   &                   \\
                                &x=2                &   &\in\mathcal{D}_x\\
    \mbox{Soit }                &x=-\sqrt[4]{16}    &   &\\
                                &x=-2               &   &\in\mathcal{D}_x\\
\end{array}
\]  
2
  • Thank you for your answers. Still, these solutions seem rather complicated to me... Is there no way to simply use \multicolumn and that the vertical lines are aligned? This would be for me the easiest... Beside, I would prefer to have the 2 first equations left aligned.
    – Garulfo
    Jul 24, 2022 at 10:34
  • Thank you so much! This is exactly what I expected! So again, thank you for your time and attention!
    – Garulfo
    Jul 25, 2022 at 9:20

You must log in to answer this question.

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