minipage 比我想要的更宽

minipage 比我想要的更宽

有时,环境的宽度minipage似乎被忽略了。我没有准确记录这种情况发生的时间。但下面是纯粹的说明性代码,显示了这个问题。

\documentclass[12pt]{article}
\usepackage{amsmath,calc}
\usepackage{lipsum}
\pagestyle{empty}
\begin{document}

\noindent
The next two boxes came out as I expected them to.\\[\baselineskip]
%%
\noindent
\fbox{\begin{minipage}[t]{0.4\textwidth-2\fboxrule-2\fboxsep}
The contents of the next line are too long to fit within this box.
\begin{align}
    \arctan(x/a) &= \frac{1}{a} \int_0^\infty \sum_{n=0}^{\infty} \left(-t^2/a^2\right)\mathrm{d}t
\end{align}
I did not use \texttt{notag} and the width of the box has \textbf{NOT} been altered.
\end{minipage}}%
\fbox{\begin{minipage}[t]{0.6\textwidth-2\fboxrule-2\fboxsep}%
    \raggedright{}
    \lipsum[22]
\end{minipage}}%

\vspace{1cm}

\noindent
The first box below does not have the width I desired.\\[\baselineskip]
%%
\noindent
\fbox{\begin{minipage}[t]{0.4\textwidth-2\fboxrule-2\fboxsep}
The contents of the next line are too long to fit within this box.
\begin{align}
    \arctan(x/a) &= \frac{1}{a} \int_0^\infty \sum_{n=0}^{\infty} \left(-t^2/a^2\right)\mathrm{d}t
    \notag
\end{align}
I used \texttt{notag} and the width of the box has been altered.
\end{minipage}}%
\fbox{\begin{minipage}[t]{0.6\textwidth-2\fboxrule-2\fboxsep}%
    \raggedright{}
    \lipsum[23]

\end{minipage}}

\end{document}

在此处输入图片描述

有人能解释一下这是怎么回事吗?我怎样才能强制第二个示例的第一个框具有我期望的宽度?

答案1

这是一个最小的例子:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\showboxdepth=5 \showboxbreadth=100 
\sbox0{\vbox{\hsize=10pt
  \noindent\begin{align*}\hbox to 15pt{}\end{align*}}}
\showbox0

\sbox0{\vbox{\hsize=10pt
  \noindent\begin{align}\hbox to 15pt{}\end{align}}}
\showbox0

\end{document}

日志文件显示

> \box0=
\hbox(29.0+0.0)x15.0
.\vbox(29.0+0.0)x15.0
..\penalty 10000
..\glue(\abovedisplayskip) 10.0 plus 2.0 minus 5.0
..\glue -3.0
..\glue 0.0
..\hbox(8.39996+3.60004)x15.0, display
...\glue(\tabskip) 0.0
...\hbox(8.39996+3.60004)x15.0
....\glue 0.0 plus 1.0fil
....\hbox(8.39996+3.60004)x0.0
.....\vbox(8.39996+3.60004)x0.0 []
....\hbox(0.0+0.0)x15.0
.....\mathon
.....\hbox(0.0+0.0)x15.0
.....\mathoff
...\glue(\tabskip) 0.0
...\hbox(8.39996+3.60004)x0.0
....\hbox(0.0+0.0)x0.0
.....\mathon
.....\hbox(0.0+0.0)x0.0
.....\mathoff
....\glue 0.0 plus 1.0fil
...\glue(\tabskip) 10.0
...etc.
..etc.

! OK.
l.8 \showbox0

> \box0=
\hbox(41.0+0.0)x10.0
.\vbox(41.0+0.0)x10.0
..\penalty 10000
..\glue(\abovedisplayskip) 10.0 plus 2.0 minus 5.0
..\glue -3.0
..\glue 0.0
..\hbox(8.39996+15.60004)x10.0, display
...\glue(\tabskip) 0.0
...\hbox(8.39996+15.60004)x15.0
....\glue 0.0 plus 1.0fil
....\hbox(8.39996+3.60004)x0.0
.....\vbox(8.39996+3.60004)x0.0 []
....\hbox(0.0+0.0)x15.0
.....\mathon
.....\hbox(0.0+0.0)x15.0
.....\mathoff
...\glue(\tabskip) 0.0
...\hbox(8.39996+15.60004)x0.0
....\hbox(0.0+0.0)x0.0
.....\mathon
.....\hbox(0.0+0.0)x0.0
.....\mathoff
....\glue 0.0 plus 1.0fil
...\glue(\tabskip) 10.0
...etc.
..etc.

! OK.
l.12 \showbox0

如你所见,第一个框的宽度为 15pt,因为在外层里面\vbox

..\hbox(8.39996+3.60004)x15.0, display

而在第二个中我们发现

..\hbox(8.39996+15.60004)x10.0, display

当必须放置方程编号(向下移动)时,似乎align会将方程式限制在总体内\hsize,但是当不需要方程编号时则不会这样做。

当使用equation/equation*gather/时,不会发生这种情况。gather*

答案2

我尝试将罪魁祸首嵌套在迷你页面中的迷你页面中。这似乎解决了问题。\vbox最内层框中可能执行的任何操作似乎都不会在超级框中继承。

\noindent
This seems to work.\\[\baselineskip]
%%
\noindent
\fbox{%
\begin{minipage}[t]{\dummy}
The contents of the next line are too long to fit within this box.\newline
\begin{minipage}{\textwidth}
\begin{align}
    \arctan(x/a) &= \frac{1}{a} \int_0^\infty \sum_{n=0}^{\infty} \left(-t^2/a^2\right)\mathrm{d}t
    \notag
\end{align}~
\end{minipage}\newline
I used \texttt{notag} and the width of the box has been altered.
\end{minipage}}%
\fbox{\begin{minipage}[t]{0.6\textwidth-2\fboxrule-2\fboxsep}%
    \raggedright{}
    \lipsum[23]
\end{minipage}}%

谢谢@egreg。如果没有你的帮助,我可能想不到这种修复方法。

相关内容