por que a largura da tabela às vezes não é respeitada?

por que a largura da tabela às vezes não é respeitada?

Eu não consigo entender isso. Eu tenho 3 mesas pequenas. Tudo pronto usando

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

Então seria de se esperar que cada tabela tivesse a mesma largura, certo? independentemente de quão amplo seja seu conteúdo. Quero dizer, a borda direita da tabela deve aparecer dentro da página, mesmo que seu conteúdo possa ultrapassar a borda direita da tabela.

Neste caso, por que recebo esta saída:

insira a descrição da imagem aqui

Aqui está o código para reproduzi-lo. Fiz questão de compilar pelo menos 3-4 vezes, apenas para garantir.

\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}

O arquivo latex e o arquivo pdf gerado, e o arquivo de log que coloquei nestepasta(link seguro, meu próprio site). UsandoLualatexcom TL 2022.

Estou fazendo algo errado? A borda direita das tabelas não deveria estar alinhada exatamente para cada tabela?

É o uso do minipageproblema? Quero usar minipagepara garantir que a linha acima da tabela e a própria tabela permaneçam na mesma página e não haja quebra de página entre elas.

Responder1

Você tem um tamanho muito grande dmathna tabular problemática e, neste caso, dmathforçará a parbox para a largura \columnwidth(breqn realmente não espera que a matemática esteja em caixas e tabulares, imho).

Usar

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

Então a equação ainda irá transbordar (já que não há ponto de interrupção), mas a direita \hline estará no lugar certo:

insira a descrição da imagem aqui

Responder2

Você pode dividir a terceira grande equação no problema 118. Isso é possível graças a breqn. E então use \textstylepara tornar a fração grande um pouco menor.

\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}

insira a descrição da imagem aqui

Responder3

  • Aparentemente, as macros do breqnpacote não funcionam em tabelas com p{width}colunas como você esperava.

  • Uma solução possível é não utilizá-lo e quebrar manualmente a equação usando amsmathambientes matemáticos ( gather, alinhado`, ...) em mais linhas quando necessário. -Para um código mais curto eu faria

    • definir novo operador \e,
    • novo comando para escrever "problema",
    • use \medmathdefinido em nccmath(que é uma extensão do pacote ˙amsmath`) quando for necessária uma fonte menor na equação.
  • MWE:

\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}
  • A proposição acima requer um pouco mais de trabalho, mas você será premiado com tabelas bonitas:

insira a descrição da imagem aqui

informação relacionada