我正在尝试复制这个练习:
现在,我有以下内容(我将为其包含一个 MWE)。
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\newcommand{\N}{\mathbb{N}}
\begin{document}
\begin{enumerate}
\item[2.] Prove the following variants of the Principle of Mathematical Induction:
\begin{enumerate}
\item For each $n\in\N$, let $P(n)$ be a proposition and let $n_0$ be some natural number. Suppose the following two results:
\begin{enumerate}[label={(\Alph*)}]
\item $P(n_0)$ is true.
\item If $P(k)$ is true, then $P(k+1)$ is also true.
\end{enumerate}
Then $P(n)$ is true for all natural numbers $n$ such that $n\geq n_0$.
\item For each $n\in\N$, let $P(n)$ be a proposition. Suppose the following two results:
\begin{enumerate}[label={(\Alph*)}]
\item $P(1)$ is true.
\item If $P(r)$ is true for all $r$ such that $1\leq r\leq k$, then $P(k+1)$ is true.
\end{enumerate}
Then $P(n)$ is true for all natural numbers $n$.
\end{enumerate}
\end{enumerate}
\end{document}
显而易见,我的复制是精确的,除了(A)-(B)列表,我不知道如何将其居中。如果我将它们封闭在环境中center
,则不会发生任何事情。如果我\centering
在枚举环境中添加,则两个项目都会单独居中。如果我使用varwidth
通常建议的解决方案(请参阅这里),我得到的格式与我想要的不同(我猜是因为我加载了包hyperref
——参见这里)。
如果您对我如何实现期望的格式有任何想法,我将非常感激,谢谢!
答案1
varwidth
hyperref
当想要设置锚点时无法开展业务。
你可以用 来模拟tabular
,如果您的项目不会太长。但是,我还添加了不同的方法,只需将项目移到比enumerate
应该做的更靠右的位置即可。
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\usepackage{varwidth}
\usepackage{hyperref}
\newcounter{tabitem}\newcounter{tabitemplus}
\newcommand{\tabitem}{\refstepcounter{tabitem}\makebox[\labelwidth][r]{\thetabitem\ }\ignorespaces}
\renewcommand{\theHtabitem}{\thetabitemplus\arabic{tabitem}}
\newenvironment{centerenum}[1][\Alph]
{%
\begin{center}
\setcounter{tabitem}{0}\stepcounter{tabitemplus}%
\renewcommand{\thetabitem}{(#1{tabitem})}%
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{@{}l@{}}
}
{\end{tabular}\end{center}}
\newcommand{\N}{\mathbb{N}}
\begin{document}
\begin{enumerate}
% tabular
\item Prove the following variants of the Principle of Mathematical Induction:
\begin{enumerate}
\item For each $n\in\N$, let $P(n)$ be a proposition and let $n_0$ be some
natural number. Suppose the following two results:
\begin{centerenum}
\tabitem\label{A1} $P(n_0)$ is true.
\\
\tabitem\label{B1} If $P(k)$ is true, then $P(k+1)$ is also true.
\end{centerenum}
Then $P(n)$ is true for all natural numbers $n$ such that $n\geq n_0$.
\item For each $n\in\N$, let $P(n)$ be a proposition. Suppose the following two results:
\begin{centerenum}
\tabitem\label{A2} $P(0)$ is true.
\\
\tabitem\label{B2} If $P(r)$ is true for all $r$ such that $0\leq r\leq k$,
then $P(k+1)$ is true.
\end{centerenum}
Then $P(n)$ is true for all natural numbers $n$.
\end{enumerate}
% wider margin
\item Prove the following variants of the Principle of Mathematical Induction:
\begin{enumerate}
\item For each $n\in\N$, let $P(n)$ be a proposition and let $n_0$ be some
natural number. Suppose the following two results:
\begin{enumerate}[label={(\Alph*)},leftmargin=4em]
\item $P(n_0)$ is true.
\item If $P(k)$ is true, then $P(k+1)$ is also true.
\end{enumerate}
Then $P(n)$ is true for all natural numbers $n$ such that $n\geq n_0$.
\item For each $n\in\N$, let $P(n)$ be a proposition. Suppose the following two results:
\begin{enumerate}[label={(\Alph*)},leftmargin=4em]
\item $P(0)$ is true.
\item If $P(r)$ is true for all $r$ such that $0\leq r\leq k$, then $P(k+1)$ is true.
\end{enumerate}
Then $P(n)$ is true for all natural numbers $n$.
\end{enumerate}
\end{enumerate}
\end{document}
我认为,第二个例子更有吸引力。
答案2
您需要将其放在一个块中,然后将其作为一个单元居中。最简单的方法是使用 a,minipage
但您需要指定宽度。另一种方法是varwidth
使用定义可变宽度 minipage 的包。(在我看来,这会变得难以阅读,我更喜欢不居中的解决方案)。
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\newcommand{\N}{\mathbb{N}}
\usepackage{varwidth}
\begin{document}
\begin{enumerate}
\item[2.] Prove the following variants of the Principle of Mathematical Induction:
\begin{enumerate}
\item For each $n\in\N$, let $P(n)$ be a proposition and let $n_0$ be some natural number. Suppose the following two results:
\begin{center}
\begin{varwidth}{\linewidth}
\begin{enumerate}[label={(\Alph*)},parsep=0pt]
\item $P(n_0)$ is true.
\item If $P(k)$ is true, then $P(k+1)$ is also true.
\end{enumerate}
\end{varwidth}
\end{center}
Then $P(n)$ is true for all natural numbers $n$ such that $n\geq n_0$.
\item For each $n\in\N$, let $P(n)$ be a proposition. Suppose the following two results:
\begin{center}
\begin{varwidth}{\linewidth}
\begin{enumerate}[label={(\Alph*)},parsep=0pt]
\item $P(1)$ is true.
\item If $P(r)$ is true for all $r$ such that $1\leq r\leq k$, then $P(k+1)$ is true.
\end{enumerate}
\end{varwidth}
\end{center}
Then $P(n)$ is true for all natural numbers $n$.
\end{enumerate}
\end{enumerate}
\end{document}