我想要两个(或三个)等式放在案例中,并希望等号对齐(这没问题)。然后我希望每行都有一些文本。文本应该右对齐,我希望在等式和文本之间有圆点,就像没有案例时一样。我不知道如何右对齐案例内的文本。这是我的代码:
\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}
答案1
这不是你想要的。我不明白为什么在 的每一行中cases
,你在行尾使用一些文本。如果是这样,你可以使用,例如$AB=CD$ \dotfill 1 point
不使用cases
。在我的回答中,在案例中,我也对所有行使用\dotfill
。
\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}
答案2
获得所需结果的简单方法,即
是使用tabularx
环境(需要tabularx
包)。事实上,上面的打印输出是使用以下代码生成的:
% 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
\newcommand*\Annadotfill{%
\leavevmode
% Do you really want "\cleaders"?
\cleaders \hb@xt@ .33em{\hss .\hss }\hfill
\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@
\def\arraystretch{1.2}% linespread: adjust as you please
\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}
然而,一定有更有效的方法,使用原始的 TeX 命令……
之前尝试过,但被我删除了
像这样吗?
这是代码:
% 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{mathtools} % also loads "amsmath"
\makeatletter
\newcommand*\annadotsfill{\leaders\hbox{.\,}\hskip 2em \@plus 1fill \relax}
\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}
不幸的是,我现在无法详细解释;我会稍后尝试编辑这个答案。