我正在打印一张课程问题表,并想将问题编号与我的解决方案文本稍微偏移一下。
根据以下回答这个问题,我尝试调整 leftskip。代码如下:
\documentclass{article}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\begin{document}
\noindent 14.5) \\
\setlength{\leftskip}{8mm} \noindent Suppose that $f(a) = f(b)$. This says that $2a + 4 = 2b + 4$, so subtracting \noindent 4 from each side and dividing by 2 yields $a = b$. We conclude that $f$ is injective. \\\\
\noindent Suppose that $c \in E$. This says $2|c $; since $\mathbb{Z}$ distributes multiplication over addition, we have (where $c = 2d$)
\begin{equation*}
c - 4 = 2d - 2(2) = 2(d-2),
\end{equation*}
\vspace{2mm}
\noindent so $c-4$ is divisible by 2; therefore $\frac{c-4}{2} \in \mathbb{Z}$. But then $f(\frac{c-4}{2})$ clearly equals $c$; so $E \subseteq f[\mathbb{Z}]$. This means that $f$ is surjective. \\\\
\noindent We conclude that $f$ is a bijection from $\mathbb{Z}$ to $E$. \\
\setlength{\leftskip}{0mm} \noindent 9.10)\\
\setlength{\leftskip}{8mm} \noindent The first statement is false (take $a=3$, $b=8$ to see that there is an integer - namely, 6 - which is in $\mathcal{D}_{ab}$ but not in $\mathcal{D}_a \bigcup \mathcal{D}_b$); the second statement is true, since $p \in \mathcal{PD}_{ab} \implies p \in \mathcal{PD}_a \lor p \in \mathcal{PD}_b$ by Euclid's Lemma (and thus $p \in \mathcal{PD}_a \bigcup \mathcal{PD}_b$), while $p \in \mathcal{PD}_{a} \bigcup \mathcal{PD}_b \implies p|a \lor p|b$, either of which says $p|ab$, so that $p \in \mathcal{PD}_{ab}$. (The second statement follows from these implications.)\\
\setlength{\leftskip}{0mm} \noindent 6.1)\\
\setlength{\leftskip}{8mm} \noindent We show that the $n$ consecutive integers following $(n+1)! + 2$, $n \geq 2$, are composite. Let $S = \{(n+1) + k: 2 \leq k \leq n+1 \}$, and let $K = \{k : 2 \leq k \leq n+1 \}$; it is clear that $S$ is a set of $n$ consecutive integers. Taking any $k$ in $K$, we consider the (obvious) corresponding $s_k = (n+1)! + k \in S$; since $k|(n+1)!$ and $k|k$, we have $k|s_k$; the quotient $\frac{(n+1)!}{k} + 1$ is greater than 1, so each $s_k$ in $S$ thus admits a non-trivial factorization (i.e., is composite). \\
\setlength{\leftskip}{0mm} \noindent 6.2)\\
\setlength{\leftskip}{8mm} \noindent We have
\begin{eqnarray*}
n^4 + 4 &=& (n^4 + 4n^2 + 4) -4n^2 \\ &=& (n^2 + 2)^2 - (2n)^2\\
&=&(n^2 - 2n + 2)(n^2 + 2n + 2);
\end{eqnarray*}
\vspace{1mm} \noindent both factors are nontrivial for $n \geq 2$. \\
\setlength{\leftskip}{0mm} \noindent 6.5) \\
\setlength{\leftskip}{8mm}
\noindent If we had $d > 1: d|m, n$, then we would have $m = \mu d, n = \nu d$;
\end{document}
代码在第一页上很好地实现了预期目的;然而,在第二页上,它不再以我想要的方式缩进问题编号。(尽管我使用了与第一页相同的命令,但它们直接出现在解决方案文本上方。)
这是怎么回事?我怎样才能得到我想要的效果?
答案1
@user1296727:请不要将以下言论当做针对我个人的;每个人都会从自己的错误中吸取教训,作为一名老师,您非常了解这一点。:-)
这完全违背了 LaTeX 的理念,逻辑结构应该进行标记,然后可以一次性定义它们的排版。
这是一个提议。
\documentclass{article}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\newcommand{\relor}{\mathrel{\lor}}
\newcommand{\divis}{\,|\,}
\newenvironment{solution}[1]
{\par\addvspace{\medskipamount}
\noindent\makebox[0pt][r]{#1) }\ignorespaces}
{\par\addvspace{\medskipamount}}
\begin{document}
\begin{solution}{14.5}
Suppose that $f(a) = f(b)$. This says that $2a + 4 = 2b + 4$, so subtracting $4$
from each side and dividing by $2$ yields $a = b$. We conclude that $f$ is injective.
Suppose that $c \in E$. This says $2\divis c$; since $\mathbb{Z}$ distributes
multiplication over addition, we have (where $c = 2d$)
\begin{equation*}
c - 4 = 2d - 2(2) = 2(d-2),
\end{equation*}
so $c-4$ is divisible by $2$; therefore $\frac{c-4}{2} \in \mathbb{Z}$.
But then $f(\frac{c-4}{2})$ clearly equals $c$; so $E \subseteq f[\mathbb{Z}]$.
This means that $f$ is surjective.
We conclude that $f$ is a bijection from $\mathbb{Z}$ to $E$.
\end{solution}
\begin{solution}{9.10}
The first statement is false (take $a=3$, $b=8$ to see that there is an
integer --~namely, 6~-- which is in $\mathcal{D}_{ab}$ but not in
$\mathcal{D}_a \cup \mathcal{D}_b$); the second statement is true,
since $p \in \mathcal{PD}_{ab} \implies p \in \mathcal{PD}_a \relor p \in \mathcal{PD}_b$
by Euclid's Lemma (and thus $p \in \mathcal{PD}_a \cup \mathcal{PD}_b$), while
$p \in \mathcal{PD}_{a} \cup \mathcal{PD}_b \implies p\divis a \relor p\divis b$, either of which
says $p\divis ab$, so that $p \in \mathcal{PD}_{ab}$. (The second statement follows from
these implications.)
\end{solution}
\begin{solution}{6.1}
We show that the $n$ consecutive integers following $(n+1)! + 2$, $n \geq 2$, are
composite. Let $S = \{(n+1) + k: 2 \leq k \leq n+1 \}$, and let
$K = \{k : 2 \leq k \leq n+1 \}$; it is clear that $S$ is a set of $n$ consecutive
integers. Taking any $k$ in $K$, we consider the (obvious) corresponding
$s_k = (n+1)! + k \in S$; since $k\divis(n+1)!$ and $k\divis k$, we have $k\divis s_k$;
the quotient $\frac{(n+1)!}{k} + 1$ is greater than 1, so each $s_k$ in $S$ thus
admits a non-trivial factorization (i.e., is composite).
\end{solution}
\begin{solution}{6.2}
We have
\begin{align*}
n^4 + 4 &= (n^4 + 4n^2 + 4) -4n^2 \\
&= (n^2 + 2)^2 - (2n)^2\\
&= (n^2 - 2n + 2)(n^2 + 2n + 2);
\end{align*}
both factors are nontrivial for $n \geq 2$.
\end{solution}
\begin{solution}{6.5}
If we had $d > 1: d\divis m, n$, then we would have $m = \mu d, n = \nu d$;
\end{solution}
\end{document}
空白处少了很多,但边距中的数字很突出,足以给出所需的强调。
\divis
注意和的定义\relor
:在栏中填充一些空间有助于区分对象;您正在将其用作\lor
关系符号,因此最好告诉 LaTeX 它是什么。
切勿使用\\
它来产生白色垂直空间,也切勿将显示的方程式与其上方的文本分开;是否应使用空行与其下方的文本分开取决于文本。
我们如何获取边距中的标签?solution
环境需要将标签作为其参数;然后它这样做\par
以确保 LaTeX 的状态并添加垂直间距(继续阅读\addvspace
)。段落以 开始\noindent
,后跟一个零宽度的框,其内容被推到右边距:由于没有空间,文本将突出在左侧。
是\ignorespaces
必需的,因为否则
\begin{solution}{14.5}
将会在“假设”前面创建一个额外的空格;所以我们将其删除。
在环境的末尾,\par
结束正在构建的任何段落并发出另一个垂直空格。但是,\addvspace
使用,因此两个连续的solution
环境将仅由一垂直空间。一般来说,当两个\addvspace
相邻时,最大空间获胜。
如果您希望解决方案文本缩进(我不推荐这样做),您可以使用与以前相同的代码,只需更改的定义solution
,例如在enumitem
包的帮助下:
\usepackage{enumitem}
\newlength{\sollabel}
\AtBeginDocument{
\settowidth{\sollabel}{00.00) }
}
\newenvironment{solution}[1]
{\begin{itemize}[leftmargin=\sollabel,labelwidth=*]\item[#1)]}
{\end{itemize}}
这应该显示为什么最好使用“逻辑结构”,而不是手动标记间距和其他所有内容。已添加模拟段落来显示结果。
关于\leftskip
:TeX 排版段落时只有一个 值\leftskip
,即段落末尾的当前值。使用
\setlength{\leftskip}{0mm} \noindent 6.5) \\
\setlength{\leftskip}{8mm}
\noindent If we had $d > 1: d|m, n$, then we would have $m = \mu d, n = \nu d$;
该段落在之后的空行处结束\setlength{\leftskip}{8mm}
,因为\\
没有\setlength{\leftskip}{8mm}
结束段落。在原始代码中,其他情况下前面都有一个空行。
答案2
我不确定为什么会发生这种情况,但很明显这是一种非常尴尬的方法。当然,你最好使用itemize
(请参阅LaTeX 入门指南(详情请见下文)。我认为,将文本放在数字下方看起来不太好看。不过,实现这一点并不难。
\documentclass{article}
\newcommand\dropitem[1]{\item[#1]\leavevmode\vskip1em}
\begin{document}
\begin{itemize}
\dropitem{14.5)} Some material that is more than one line long, so we can see
that the indentation is still correct.
\dropitem{9.10)} More stuff
\end{itemize}
\end{document}