# Alignment and dotfill in cases

This is what I want: This is what I get:

I want two (or three) equations in cases and I want to align the equal sign (that's no problem). And then I want to have some text in every row. The text should be right aligned and I want dots between the equation and the text, just like it is when I don't have cases. I don't know how to right align the texts inside the cases. Here is my code:

\documentclass[a5paper]{book}

\usepackage[top=1.8cm, bottom=2.7cm, left=2.7cm, right=1.8cm]{geometry}

\usepackage{amsthm,amsmath}

\makeatletter
\renewcommand \dotfill {\leavevmode \cleaders \hb@xt@ .33em{\hss .\hss }\hfill \kern \z@}
\makeatother

\newenvironment{lcases}
{\left\lbrace\begin{aligned}}
{\end{aligned}\right.}

\begin{document}
\begin{enumerate}
\item $AB=CD$ \dotfill text
\item $AB=CD$ \dotfill more text
\item $\begin{lcases} &GB=DE \leaders\hbox{\hss .\hss }\hskip \textwidth minus \textwidth \text{text}\\ &AB=CD \leaders\hbox{\hss .\hss }\hskip \textwidth minus \textwidth \text{more text} \end{lcases}$
\end{enumerate}
\end{document}

• What do you mean by "right align"? Is the text flush right with the page margin? Or are they just somewhere on the right and right-aligned with one another? Jun 2 '18 at 15:46
• raggedleft (just the text in the cases), the equation should be where they are. I uploaded new pictures. Jun 2 '18 at 17:09

This is not what you want. I don't understand why in each line of cases, you use some text at the end of line. If so, you can use, for example $AB=CD$ \dotfill 1 point without using cases. In my answer, in the cases, I also use \dotfill for all lines.

\documentclass[a5paper]{book}
\usepackage[top=1.8cm, bottom=2.7cm, left=2.7cm, right=1.8cm]{geometry}
\usepackage{amsthm,amsmath}
\begin{document}
\begin{enumerate}
\item $AB=CD$ \dotfill 1 point
\item $AB=CD$ \dotfill 2 points
\item $\begin{cases} GB=DE\\ AB=CD. \end{cases}$ \dotfill 2 points
\end{enumerate}
\end{document}


An easy way to obtain the desired result, namely

is to use the tabularx environment (requires the tabularx package). Indeed, the above printout has been produced with the following code:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath}
\usepackage{tabularx}

\makeatletter

\leavevmode
% Do you really want "\cleaders"?
\kern \z@
}
\@ifdefinable\@Anna@brace@width{\newdimen\@Anna@brace@width}
\settowidth\@Anna@brace@width{%
$\left\{\vbox{\vskip \@m \p@}\right.\kern -\nulldelimiterspace$%
}
\newenvironment{Annacases}{%
\left\{%
\tabcolsep \z@
\tabularx{\dimexpr \linewidth-\@Anna@brace@width \relax}%
{>{$}r<{$}>{${}}X<{$}}%
}{%
\endtabularx
\right.%
\kern -\nulldelimiterspace
}

\makeatother

\begin{document}

Some text before the enumeration.
\begin{enumerate}
\item $AB=CD$ \Annadotfill text;
\item $AB=CD$ \Annadotfill longer text;
\item
$\begin{Annacases} AB &= CD\Annadotfill\text{text;}\\ AB &= CD+EF+GH\Annadotfill\text{longer text;}\\ MN+XY &= PQ\Annadotfill\text{longer text, and more.} \end{Annacases}$
\end{enumerate}
Some text after the enumeration.

\end{document}


However, there must be a more efficient method, using primitive TeX commands…

# Previous Attempt, Which I Had Deleted

Something like this?

This is the code:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\makeatletter

\newcases{annacases}
{} % separation between columns
{$\m@th\displaystyle\hfil##$} % left preamble
{$\m@th\displaystyle{}##$} % right preambel
{\lbrace}{.} % delimiters

\makeatother

\begin{document}

Some text before the equation.
$\begin{annacases} AB &= CD\annadotsfill\text{text}\\ AB &= CD+EF+GH\annadotsfill\text{longer text}\\ MN+XY &= PQ\annadotsfill\text{longer text, and more} \end{annacases}$
Some text after the equation.

\end{document}


Unfortunately, I cannot dwell on explanations right now; I’ll try to edit this answer later on.

• Thanks! It works perfect. But when I try to get wide in enumerate it doesn't work and the same for if I use hspace before the Annacases. I post a new question because this was not in my origin question. Jun 4 '18 at 9:41