线条超出了 PDF 边界吗?

线条超出了 PDF 边界吗?

我有几行方程超出了 PDF 的边界,我希望它们适合 PDF。然而,发生了以下情况:

我有代码:

\documentclass[11pt,fleqn]{article}
\setlength {\topmargin} {-.15in}
\setlength {\textheight} {8.6in}

\usepackage{amsmath}   
\usepackage{amssymb}
\usepackage{amsthm}

\renewcommand{\labelenumii}{\theenumii.}

\newcommand{\mname}[1]{\mbox{\sf #1}}
\newcommand{\pnote}[1]{{\langle \text{#1} \rangle}}

\begin{document}

\medskip

\noindent

\subsection*{Required Problems}

\begin{enumerate}

  \item \textbf{[10 points]} Prove by weak induction
that \[\sum^{n}_{i=0}i^2 = \frac{n(n+1)(2n +1)}{6}\] for all $n
\in \mathbb{N}$.

\bigskip

\begin{proof}
Let $P\,n \equiv \sum^{n}_{i=0}i^2 = \frac{n(n+1)(2n +1)}{6}$. Proving $P\,n$
 for all $n \in \mathbb{N}$ by weak induction.

\emph{Base case}: $n = 0$.

\begin{align*}
P\,0 & \equiv \sum_{i=0}^{0} {i}^2 = \frac{0(0+1)(2*0 +1)}{6} & 
\pnote{definition of $P$}\\
     & \equiv 0^2 = \frac{0(0+1)(2*0 +1)}{6} & \pnote{definition of $\sum_{i=m}^{n} f\,i$}\\
     & \equiv 0 = \frac{0(1)(1)}{6} & \pnote{arithmetic}\\
     & \equiv 0 = 0         & \pnote{arithmetic}
\end{align*}

\emph{Induction step}: Assuming $P\,n$. Proving $P\,(n + 1)$.

\begin{flalign*}
P\,(n+1) & \equiv \sum_{i=0}^{n + 1} {i}^2 = \frac{(n+1)(n+2)(2(n+1) +1)}{6} & \pnote{definition of $P$}\\
         & \equiv {(n+1)}^2 + \sum_{i=0}^{n} {i}^2 = \frac{(n+1)(n+2)(2(n+1) +1)}{6} & \pnote{definition of $\sum_{i=m}^{n} f\,i$}\\
         & \equiv {(n^2+2n+1)} + \sum_{i=0}^{n} {i}^2 = 
\frac{(n^2+3n+2)(2n+3)}{6} & \pnote{arithmetic}\\
         & \equiv {(n^2+2n+1)} + \sum_{i=0}^{n} {i}^2 = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\ 
         & \equiv {(n^2+2n+1)} + \frac{n(n+1)(2n +1)}{6} = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{induction hypothesis}\\
         & \equiv \frac{(6n^2+12n+6)}{6} + \frac{(n^2+n)(2n +1)}{6} = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\
         & \equiv \frac{(6n^2+12n+6+2n^3+n^2+2n^2+n)}{6} = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\
         & \equiv \frac{(2n^3+9n^2+13n+6)}{6} = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\
\end{flalign*}

\end{proof}



\end{enumerate} 

\end{document}

请注意,我是 LaTeX 的完全初学者。

答案1

可能是这样的吗?假设是美国信纸。(我猜这是正确的,因为你使用的是英寸。)

我已习惯geometry加宽文本块并将enumitem第一级枚举设置在左边距。我还更新了过时的\sf字体命令。根据预期用途,您可能需要\mathsf{}或此处。\textsf{}

输出

\documentclass[11pt,fleqn]{article}
\usepackage[height=8.6in,hscale=.85]{geometry}
\usepackage{amsmath}   
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{enumitem}
\setlist[enumerate,2]{label=\arabic*.}
\setlist[enumerate,1]{align=left, leftmargin=\parindent, labelwidth=*}

\newcommand{\mname}[1]{\mbox{\sffamily #1}}
\newcommand{\pnote}[1]{{\langle \text{#1} \rangle}}

\begin{document}

\subsection*{Required Problems}

\begin{enumerate}

  \item  \textbf{[10 points]} Prove by weak induction
  that \[\sum^{n}_{i=0}i^2 = \frac{n(n+1)(2n +1)}{6}\] for all $n
  \in \mathbb{N}$.

  \bigskip

  \begin{proof}
    Let $P\,n \equiv \sum^{n}_{i=0}i^2 = \frac{n(n+1)(2n +1)}{6}$. Proving $P\,n$
    for all $n \in \mathbb{N}$ by weak induction.

    \emph{Base case}: $n = 0$.

    \begin{align*}
      P\,0 & \equiv \sum_{i=0}^{0} {i}^2 = \frac{0(0+1)(2*0 +1)}{6} & 
      \pnote{definition of $P$}\\
      & \equiv 0^2 = \frac{0(0+1)(2*0 +1)}{6} & \pnote{definition of $\sum_{i=m}^{n} f\,i$}\\
      & \equiv 0 = \frac{0(1)(1)}{6} & \pnote{arithmetic}\\
      & \equiv 0 = 0         & \pnote{arithmetic}
    \end{align*}

    \emph{Induction step}: Assuming $P\,n$. Proving $P\,(n + 1)$.

    \begin{flalign*}
      P\,(n+1) & \equiv \sum_{i=0}^{n + 1} {i}^2 = \frac{(n+1)(n+2)(2(n+1) +1)}{6} & \pnote{definition of $P$}\\
      & \equiv {(n+1)}^2 + \sum_{i=0}^{n} {i}^2 = \frac{(n+1)(n+2)(2(n+1) +1)}{6} & \pnote{definition of $\sum_{i=m}^{n} f\,i$}\\
      & \equiv {(n^2+2n+1)} + \sum_{i=0}^{n} {i}^2 = 
      \frac{(n^2+3n+2)(2n+3)}{6} & \pnote{arithmetic}\\
      & \equiv {(n^2+2n+1)} + \sum_{i=0}^{n} {i}^2 = 
      \frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\ 
      & \equiv {(n^2+2n+1)} + \frac{n(n+1)(2n +1)}{6} = 
      \frac{(2n^3+9n^2+13n+6)}{6} & \pnote{induction hypothesis}\\
      & \equiv \frac{(6n^2+12n+6)}{6} + \frac{(n^2+n)(2n +1)}{6} = 
      \frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\
      & \equiv \frac{(6n^2+12n+6+2n^3+n^2+2n^2+n)}{6} = 
      \frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\
      & \equiv \frac{(2n^3+9n^2+13n+6)}{6} = 
      \frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\
    \end{flalign*}

  \end{proof}

\end{enumerate} 

\end{document}

答案2

如果有人需要的话,还有一个额外的解决方案:

\documentclass[11pt,fleqn]{article}
\setlength {\topmargin} {-.15in} %NOT SUGGESTED
\setlength {\textheight} {8.6in} %NOT SUGGESTED

\usepackage{amsmath}   
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{varwidth}

\renewcommand{\labelenumii}{\theenumii.}

\newcommand{\mname}[1]{\mbox{\sf #1}} %%%SEE cfr's comment->NOT SUGGESTED
\newcommand{\pnote}[1]{{\langle \text{#1} \rangle}}





\begin{document}

\medskip

\noindent

\subsection*{Required Problems}

\begin{enumerate}

  \item \textbf{[10 points]} Prove by weak induction
that \[\sum^{n}_{i=0}i^2 = \frac{n(n+1)(2n +1)}{6}\] for all $n
\in \mathbb{N}$.

\bigskip

\begin{proof}
Let $P\,n \equiv \sum^{n}_{i=0}i^2 = \frac{n(n+1)(2n +1)}{6}$. Proving $P\,n$
 for all $n \in \mathbb{N}$ by weak induction.

\emph{Base case}: $n = 0$.

\begin{align*}
P\,0 & \equiv \sum_{i=0}^{0} {i}^2 = \frac{0(0+1)(2*0 +1)}{6} & 
\pnote{definition of $P$}\\
     & \equiv 0^2 = \frac{0(0+1)(2*0 +1)}{6} & \pnote{definition of $\sum_{i=m}^{n} f\,i$}\\
     & \equiv 0 = \frac{0(1)(1)}{6} & \pnote{arithmetic}\\
     & \equiv 0 = 0         & \pnote{arithmetic}
\end{align*}

\emph{Induction step}: Assuming $P\,n$. Proving $P\,(n + 1)$.

\hspace*{-85pt}\begin{minipage}{0.8\textwidth}
\begin{flalign*}
P\,(n+1) & \equiv \sum_{i=0}^{n + 1} {i}^2 = \frac{(n+1)(n+2)(2(n+1) +1)}{6} & \pnote{definition of $P$}\\
         & \equiv {(n+1)}^2 + \sum_{i=0}^{n} {i}^2 = \frac{(n+1)(n+2)(2(n+1) +1)}{6} & \pnote{definition of $\sum_{i=m}^{n} f\,i$}\\
         & \equiv {(n^2+2n+1)} + \sum_{i=0}^{n} {i}^2 = 
\frac{(n^2+3n+2)(2n+3)}{6} & \pnote{arithmetic}\\
         & \equiv {(n^2+2n+1)} + \sum_{i=0}^{n} {i}^2 = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\ 
         & \equiv {(n^2+2n+1)} + \frac{n(n+1)(2n +1)}{6} = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{induction hypothesis}\\
         & \equiv \frac{(6n^2+12n+6)}{6} + \frac{(n^2+n)(2n +1)}{6} = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\
         & \equiv \frac{(6n^2+12n+6+2n^3+n^2+2n^2+n)}{6} = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\
         & \equiv \frac{(2n^3+9n^2+13n+6)}{6} = 
\frac{(2n^3+9n^2+13n+6)}{6} & \pnote{arithmetic}\\
\end{flalign*}
\end{minipage}

\end{proof}
\end{enumerate}
\end{document}

输出:

在此处输入图片描述

此解决方案保留其余文本的边距,并将内容放在中间...

答案3

@cfr 和 @koleygr 确实是提供答案的人。但由于问题的标题非常笼统,我想提供一个讨论,以便其他人通过后续搜索找到此问题。

TeX 能够写出比页面宽度更宽的行。它还能够(在某些情况下)写出超出页面底部的内容。如果您提供更奇特的代码,它甚至可以写出超出页面左侧和顶部的内容。

不管你信不信,这在 PDF 中是允许的。这就是 TeX 编译器不会因错误而停止的原因。PDF 阅读器将能够显示该文件(但部分文本或图像会被截断)。文本并没有消失;它被埋在 PDF 中,但你看不到它。

PDF 知道,这就是您要做的事情!它无法读懂您的想法。

在商业印刷领域,超出页面边缘是不允许的。除非在某些情况下,否则甚至不允许接近页面边缘。但这不是这里的问题。

如上所述,在原始示例中,代码要求行的长度大于页面宽度。有两种解决方案:缩短行,或加宽页面。

通过在选定的点处断开行可以缩短行。在数学中,你必须仔细选择,甚至重写表达式,以便人们能够理解。如果你的读者会看到它打印在纸上,这可能是最好的方法。

加宽页面比较容易,要么在文档类中选择不同的页面大小,要么使用“几何”包。如果观众只能在电脑屏幕上看到它,这可能是最好的方法,因为读者可以左右滚动。如果打印到纸上,文本可能需要缩小,以适应物理纸张尺寸。

相关内容