為什麼有時不遵守表格寬度?

為什麼有時不遵守表格寬度?

我想不通這個。我有3張小桌子。全部設定使用

\begin{tabular}{|p{.6in}|p{5.5in}|}\hline

所以人們會期望每個表格的寬度都相同,對吧?無論其內容有多麼廣泛。我的意思是表格的右邊緣應該顯示在頁面內,即使其內容可能溢出到表格右邊緣之外。

在這種情況下,為什麼我會得到這個輸出:

在此輸入影像描述

這是重現它的程式碼。我確保至少編譯 3-4 次,以防萬一。

\documentclass[12pt]{book}
\raggedbottom
\usepackage[letterpaper,bindingoffset=0.2in,%
            left=0.9in,right=1in,top=1in,bottom=1in,%
            footskip=.25in]{geometry}

\usepackage{amsmath}
\usepackage{breqn}
\DeclareMathOperator{\RootOf}{RootOf}

\begin{document}
\begin{minipage}{\textwidth}
\textbf{Problem} 117

\begin{tabular}{|p{.6in}|p{5.5in}|}\hline    
ODE&%\vspace{-2em}
\begin{gather*}
\boxed{3 y^{3} x^{2}+y^{4}+\left(3 y^{2} x^{3}+4 x y^{3}+y^{4}\right) y^{\prime}=0}
\end{gather*}
\\ \hline
program solution&
\begin{dmath*}
y \left(x \right) = 0
\end{dmath*}
Verified OK. 
\\ \hline
Maple solution&
\begin{dgroup*}
\begin{dmath*}
y \left(x \right) = 0                        
\end{dmath*}
\begin{dmath*}
x y \left(x \right)^{4}+y \left(x \right)^{3} x^{3}+\frac{y \left(x \right)^{5}}{5}+c_{1} = 0                        
\end{dmath*}
\end{dgroup*}
\\ \hline
\end{tabular}
\end{minipage}
\normalsize

\begin{minipage}{\textwidth}
\textbf{Problem} 118

\begin{tabular}{|p{.6in}|p{5.5in}|}\hline    
ODE&%\vspace{-2em}
\begin{gather*}
\boxed{{\mathrm e}^{x} \sin \left(y\right)+\tan \left(y\right)+\left({\mathrm e}^{x} \cos \left(y\right)+x \left(\sec^{2}\left(y\right)\right)\right) y^{\prime}=0}
\end{gather*}
\\ \hline
program solution&
\begin{dmath*}
{\mathrm e}^{x} \sin \left(y \left(x \right)\right)+x \tan \left(y \left(x \right)\right) = c_{1}
\end{dmath*}
Verified OK. 
\\ \hline
Maple solution&
\begin{dmath*}
y \left(x \right) = \arctan \left(-\frac{c_{1} \RootOf \left(\textit{\_Z}^{4} {\mathrm e}^{2 x}+2 x \,{\mathrm e}^{x} \textit{\_Z}^{3}+\left(c_{1}^{2}+x^{2}-{\mathrm e}^{2 x}\right) \textit{\_Z}^{2}-2 x \,{\mathrm e}^{x} \textit{\_Z} -x^{2}\right)}{\RootOf \left(\textit{\_Z}^{4} {\mathrm e}^{2 x}+2 x \,{\mathrm e}^{x} \textit{\_Z}^{3}+\left(c_{1}^{2}+x^{2}-{\mathrm e}^{2 x}\right) \textit{\_Z}^{2}-2 x \,{\mathrm e}^{x} \textit{\_Z} -x^{2}\right) {\mathrm e}^{x}+x}, \RootOf \left(\textit{\_Z}^{4} {\mathrm e}^{2 x}+2 x \,{\mathrm e}^{x} \textit{\_Z}^{3}+\left(c_{1}^{2}+x^{2}-{\mathrm e}^{2 x}\right) \textit{\_Z}^{2}-2 x \,{\mathrm e}^{x} \textit{\_Z} -x^{2}\right)\right)                        
\end{dmath*}
\\ \hline
\end{tabular}
\end{minipage}
\normalsize


\begin{minipage}{\textwidth}
\textbf{Problem} 119

\begin{tabular}{|p{.6in}|p{5.5in}|}\hline    
ODE&%\vspace{-2em}
\begin{gather*}
\boxed{\frac{2 x}{y}-\frac{3 y^{2}}{x^{4}}+\left(-\frac{x^{2}}{y^{2}}+\frac{1}{\sqrt{y}}+\frac{2 y}{x^{3}}\right) y^{\prime}=0}
\end{gather*}
\\ \hline
program solution&
\begin{dmath*}
\frac{x^{2}}{y \left(x \right)}+\frac{y \left(x \right)^{2}}{x^{3}}+2 \sqrt{y \left(x \right)} = c_{1}
\end{dmath*}
Verified OK. 
\\ \hline
Maple solution&
\begin{dmath*}
\frac{y \left(x \right)^{2}}{x^{3}}+\frac{x^{2}}{y \left(x \right)}+2 \sqrt{y \left(x \right)}+c_{1} = 0                        
\end{dmath*}
\\ \hline
\end{tabular}
\end{minipage}
\normalsize
\end{document}

產生的乳膠文件和pdf文件,以及我放入此的日誌文件資料夾(安全鏈接,我自己的網站)。使用盧拉泰克斯與 TL 2022。

難道我做錯了什麼?每個表格的右邊緣不應該完全對齊嗎?

是使用的minipage問題嗎?我想用它minipage來確保表格上方的行和表格本身保留在同一頁上,並且它們之間沒有分頁符號。

答案1

有問題的表格中有一個非常大的dmath表格,在這種情況下,dmath將迫使 parbox 達到寬度\columnwidth(breqn 並不真正期望數學位於方框和表格中)。

使用

\usepackage{array}
....
\begin{tabular}{|p{.6in}|>{\setlength\columnwidth{5.5in}}p{5.5in}|}\hline

那麼方程式仍然會溢出(因為沒有斷點),但右邊\hline 將在正確的位置:

在此輸入影像描述

答案2

breqn您可以拆分問題 118 中的第三個大方程式。然後使用\textstyle將大分數變小一點。

\documentclass[12pt]{book}
\raggedbottom
\usepackage[letterpaper,bindingoffset=0.2in,%
            left=0.9in,right=1in,top=1in,bottom=1in,%
            footskip=.25in]{geometry}

\usepackage{amsmath}
\usepackage{breqn}
\DeclareMathOperator{\RootOf}{RootOf}

\begin{document}
\begin{minipage}{\textwidth}
\textbf{Problem} 117

\begin{tabular}{|p{.6in}|p{5.5in}|}\hline    
ODE&%\vspace{-2em}
\begin{gather*}
\boxed{3 y^{3} x^{2}+y^{4}+\left(3 y^{2} x^{3}+4 x y^{3}+y^{4}\right) y^{\prime}=0}
\end{gather*}
\\ \hline
program solution&
\begin{dmath*}
y \left(x \right) = 0
\end{dmath*}
Verified OK. 
\\ \hline
Maple solution&
\begin{dgroup*}
\begin{dmath*}
y \left(x \right) = 0                        
\end{dmath*}
\begin{dmath*}
x y \left(x \right)^{4}+y \left(x \right)^{3} x^{3}+\frac{y \left(x \right)^{5}}{5}+c_{1} = 0                        
\end{dmath*}
\end{dgroup*}
\\ \hline
\end{tabular}
\end{minipage}
\normalsize

\begin{minipage}{\textwidth}
\textbf{Problem} 118

\begin{tabular}{|p{.6in}|p{5.5in}|}\hline    
ODE&%\vspace{-2em}
\begin{gather*}
\boxed{{\mathrm e}^{x} \sin \left(y\right)+\tan \left(y\right)+\left({\mathrm e}^{x} \cos \left(y\right)+x \left(\sec^{2}\left(y\right)\right)\right) y^{\prime}=0}
\end{gather*}
\\ \hline
program solution&
\begin{dmath*}
{\mathrm e}^{x} \sin \left(y \left(x \right)\right)+x \tan \left(y \left(x \right)\right) = c_{1}
\end{dmath*}
Verified OK. 
\\ \hline
Maple solution&
\begin{dmath*}\textstyle
y \left(x \right) = \arctan \left(-\frac{c_{1} \RootOf \left(\textit{\_Z}^{4} {\mathrm e}^{2 x}+2 x \,{\mathrm e}^{x} \textit{\_Z}^{3}+\left(c_{1}^{2}+x^{2}-{\mathrm e}^{2 x}\right) \textit{\_Z}^{2}-2 x \,{\mathrm e}^{x} \textit{\_Z} -x^{2}\right)}{\RootOf \left(\textit{\_Z}^{4} {\mathrm e}^{2 x}+2 x \,{\mathrm e}^{x} \textit{\_Z}^{3}+\left(c_{1}^{2}+x^{2}-{\mathrm e}^{2 x}\right) \textit{\_Z}^{2}-2 x \,{\mathrm e}^{x} \textit{\_Z} -x^{2}\right) {\mathrm e}^{x}+x},\\ \RootOf \left(\textit{\_Z}^{4} {\mathrm e}^{2 x}+2 x \,{\mathrm e}^{x} \textit{\_Z}^{3}+\left(c_{1}^{2}+x^{2}-{\mathrm e}^{2 x}\right) \textit{\_Z}^{2}-2 x \,{\mathrm e}^{x} \textit{\_Z} -x^{2}\right)\right)                        
\end{dmath*}
\\ \hline
\end{tabular}
\end{minipage}
\normalsize


\begin{minipage}{\textwidth}
\textbf{Problem} 119

\begin{tabular}{|p{.6in}|p{5.5in}|}\hline    
ODE&%\vspace{-2em}
\begin{gather*}
\boxed{\frac{2 x}{y}-\frac{3 y^{2}}{x^{4}}+\left(-\frac{x^{2}}{y^{2}}+\frac{1}{\sqrt{y}}+\frac{2 y}{x^{3}}\right) y^{\prime}=0}
\end{gather*}
\\ \hline
program solution&
\begin{dmath*}
\frac{x^{2}}{y \left(x \right)}+\frac{y \left(x \right)^{2}}{x^{3}}+2 \sqrt{y \left(x \right)} = c_{1}
\end{dmath*}
Verified OK. 
\\ \hline
Maple solution&
\begin{dmath*}
\frac{y \left(x \right)^{2}}{x^{3}}+\frac{x^{2}}{y \left(x \right)}+2 \sqrt{y \left(x \right)}+c_{1} = 0                        
\end{dmath*}
\\ \hline
\end{tabular}
\end{minipage}
\normalsize
\end{document}

在此輸入影像描述

答案3

  • 顯然,套件中的巨集breqn不能p{width}像您預期的那樣在包含列的表中工作。

  • 一個可能的解決方案是不使用它,並在需要時在更多行中使用amsmath數學環境( 、aligned` 等)手動打破方程式。 gather- 對於較短的程式碼我會

    • 定義新的運算符\e
    • 用於編寫“問題”的新命令,
    • 當方程式中需要較小的字體時,使用(這是 ˙amsmath` 包的擴展)\medmath中定義的。nccmath
  • 微量元素:

\documentclass[12pt]{book}
\raggedbottom
\usepackage[letterpaper,bindingoffset=0.2in,%
            left=0.9in,right=1in,top=1in,bottom=1in,%
            footskip=.25in]{geometry}

\usepackage{nccmath}
\DeclareMathOperator{\e}{\mathrm{e}}
\DeclareMathOperator{\RootOf}{RootOf}
%\usepackage{breqn}

\newcommand\problem[1]{\par      
                       \bigskip\textbf{Problem}~#1\par
                       \medskip}

\begin{document}

\problem{117}
\begin{tabular}{|p{0.6in}|p{5.5in}|}
    \hline
ODE &   \[
    \boxed{3 y^{3} x^{2}+y^{4} + (3 y^{2}x^{3} + 4 xy^{3} + y^{4}t) y^{\prime}=0}
        \]   \\ 
    \hline
program solution
    &   \[
    y(x) = 0
        \]
        Verified OK.    \\ 
    \hline
Maple solution
    &   \[\begin{aligned}
    y(x)    & = 0       \\
    xy(x)^{4} + y(x)^{3} x^{3} + \frac{y(x)^{5}}{5} + c_{1} 
            & = 0
        \end{aligned}\]   \\ 
    \hline
\end{tabular}

\problem{118}
\begin{tabular}{|p{0.6in}|p{5.5in}|}
    \hline
ODE & \begin{gather*}
\boxed{{\mathrm e}^{x} \sin \left(y\right)+\tan \left(y\right)+\left({\mathrm e}^{x} \cos \left(y\right)+x \left(\sec^{2}\left(y\right)\right)\right) y^{\prime}=0}
\end{gather*}   \\ 
    \hline
program solution
    &   \[
    \mathrm{e}^{x} \sin \left(y \left(x \right)\right) + x \tan \left(y \left(x \right)\right) = c_{1}
        \]
    Verified OK.    \\ 
    \hline
Maple solution
    &   \[\medmath{
        \begin{aligned}
    y(x) & = \arctan \biggl(
    -\frac{c_{1} \RootOf\bigl(\_Z^{4} \e^{2 x}+2 x \,\e^{x} \_Z^{3} + (c_{1}^{2}+x^{2}-\e^{2 x}) \_Z^{2}-2 x \,\e^{x} \_Z -x^{2}\bigr)}
          {\RootOf\bigl(\_Z^{4} \e^{2 x}+2 x \e^{x} \_Z^{3} + (c_{1}^{2}+x^{2} - \e^{2 x}) \_Z^{2} - 2 x \e^{x} \_Z  - x^{2}\bigr) \e^{x} + x}, \\
    &\quad  \RootOf\bigl(\_Z^{4} \e^{2 x}+2 x \,\e^{x} \_Z^{3} + (c_{1}^{2}+x^{2}-\e^{2 x} ) \_Z^{2}-2 x \,\e^{x} \_Z -x^{2}\bigr)
    \biggr)
        \end{aligned}}\]    \\
    \hline
\end{tabular}

\end{document}
  • 上述建議需要更多的工作,但您將獲得漂亮的表格:

在此輸入影像描述

相關內容