1

I'm compiling a list of math exercises with solutions: I would like to left-align the exercise numbers and to right-align the results. I have tried the flalign* environment, but it doesn't work well. This is a working example:

\documentclass[12pt,a4paper]{article}
\usepackage[italian]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{mathtools}

\usepackage{multicol}


\begin{document}
\pagestyle{empty}

\begin{flalign*}
1) &\; \frac{3}{4}x^2-\frac{8}{3}=0 & \left[ \pm\frac{4}{3}\sqrt{2} \right]&\\ 
2) &\; 3x-\sqrt{3}x^2=0 & \left[0,\sqrt{3}\right]&\\
3) &\; \frac{1}{25}x^2+\frac{2}{5}x+1=0 & \left[ -5\text{ doppia}\right]&\\
4) &\; -\frac{1}{4}x^2+\frac{7}{6}x+2=0 & \left[-\frac{4}{3}, 6\right]&\\
\end{flalign*}

\end{document}

This is the result: the square parentheses are not right-aligned very well. What am I doing wrong?

enter image description here

2
  • What do you mean in "the square parentheses are not right-aligned very well"? You want the four pair of square parentheses having the same width? Commented Jun 22, 2020 at 19:59
  • I want them right-aligned, they are not now.
    – zar
    Commented Jun 22, 2020 at 21:30

2 Answers 2

2

The width of \left[ \right] brackets automatically changes depending on the height of the contents. You must use \vphantom{} command with some argument that is larger than any argument of the right-aligned contents

For example, you might want to use \vphantom{\frac{1}{4}x^2} in any place inside the contents of the brackets. For a neat way, it is better to define a new command

enter image description here

\documentclass[12pt,a4paper]{article}

\usepackage{mathtools}
        
\begin{document}
    
\begin{flalign*}
    1) &\; \frac{3}{4}x^2-\frac{8}{3}=0 & \left[ \pm\frac{4}{3}\sqrt{2} \largevPhantom \right]\\ 
    2) &\; 3x-\sqrt{3}x^2=0 & \left[0,\sqrt{3} \largevPhantom \right]\\
    3) &\; \frac{1}{25}x^2+\frac{2}{5}x+1=0 & \left[ -5\text{ doppia} \largevPhantom \right]\\
    4) &\; -\frac{1}{4}x^2+\frac{7}{6}x+2=0 & \left[-\frac{4}{3}, 6 \largevPhantom \right]\\
\end{flalign*}


\end{document}

Another option (does not use \vphantom) is to use bigg[ \bigg]

\documentclass[12pt,a4paper]{article}

\usepackage{mathtools}
        
\begin{document}

\begin{flalign*}
    1) &\; \frac{3}{4}x^2-\frac{8}{3}=0 & \bigg[ \pm\frac{4}{3}\sqrt{2}  \bigg]\\ 
    2) &\; 3x-\sqrt{3}x^2=0 & \bigg[0,\sqrt{3} \bigg]\\
    3) &\; \frac{1}{25}x^2+\frac{2}{5}x+1=0 & \bigg[ -5\text{ doppia} \bigg]\\
    4) &\; -\frac{1}{4}x^2+\frac{7}{6}x+2=0 & \bigg[ -\frac{4}{3}, 6 \bigg]\\
\end{flalign*}


\end{document}
2
  • I see. In this way, all the brackets will be the same size. Does it exist a way to align brackets with different vertical sizes? Perhaps substituting flalign with another environment?
    – zar
    Commented Jun 22, 2020 at 21:33
  • 1
    It would also be good to use bigg for brackets Commented Jun 22, 2020 at 21:55
1

If there's something I hate, it's exercises with the solutions at the right margin. ;-)

The brackets are aligned, the only problem is that they have different sizes. You can alleviate the problem by using smaller ones, for instance, and separating them vertically a bit more. Anyway, flalign is not the right choice to begin with.

\documentclass[12pt,a4paper]{article}
\usepackage[italian]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{fixcmex} % important if you use lmodern with math
\usepackage{mathtools}
\usepackage{enumitem}


\begin{document}

\begin{enumerate}[wide,label=\arabic*),itemsep=1ex]
\item  $\displaystyle\frac{3}{4}x^2-\frac{8}{3}=0$\hfill
       $\displaystyle\Bigl[\, \pm\frac{4}{3}\sqrt{2} \,\Bigr]$

\item $\displaystyle 3x-\sqrt{3}x^2=0$\hfill
      $\displaystyle\bigl[\, 0,\sqrt{3} \,\bigr]$

\item $\displaystyle\frac{1}{25}x^2+\frac{2}{5}x+1=0$\hfill
      $\displaystyle[\, -5\text{ doppia} \,]$

\item $\displaystyle-\frac{1}{4}x^2+\frac{7}{6}x+2=0$\hfill
      $\displaystyle\Bigl[\, -\frac{4}{3}, 6 \,\Bigr]$
\end{enumerate}

\end{document}

I added thin spaces at either side in order to separate the solution from the delimiters (which are not really mathematical delimiters) and avoided \left and \right preferring \Big size when fractions are involved.

enter image description here

1
  • But the brackets are not aligned: notice the third one (I didn't use the enumerate environment because I use another macro to keep track of the exercise number).
    – zar
    Commented Jun 23, 2020 at 7:39

You must log in to answer this question.

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