我尝试按照一些建议为带有方程式的单元格添加垂直空间,但无法实现。
这是我的 MWE:
\documentclass[12pt,a4paper]{article}
\usepackage{array}
\usepackage{makecell}
\renewcommand\theadfont{\normalsize\bfseries}
\usepackage[math]{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\usepackage{color,colortbl,hhline}
\definecolor{Gray}{gray}{0.9}
\usepackage{caption}
\usepackage{amsmath}
\begin{document}
\begin{table}[htpb]
\centering
\caption{Solución de la ecuación }
\begin{tabular}{|p{1cm}|p{12cm}|}
\hline
\rowcolor{Gray} \thead{Caso} & \thead{Solución} \\
\hline
$\zeta = 1$ & $u(t) = [u(0) + (\dot u(0) + u(0) \omega_n )t]e^{-\omega_n t}$\\\hline
$\zeta > 1$ & $u(t) = \dfrac{e^{-\omega_n\zeta}}{2\omega_n\sqrt{\zeta^2-1}}\left\lbrace\left[\omega_n(\zeta+\sqrt{\zeta^2-1})u(0)+\dot u(0)\right]e^{\omega_n\sqrt{\zeta^2-1}}-\big[\omega_n(\zeta - \sqrt{\zeta^2-1})u(0)+\dot u(0)\big]e^{-\omega_n\sqrt{\zeta^2-1}}\right\rbrace$ \\\hline
$\zeta < 1$ & $u(t) = e^{-\omega_n\zeta t}\left[u(0)\cos{\omega_Dt} + \left(\dfrac{\dot u(0) + \omega_n\zeta u(0)}{\omega_D}\right)\right]$ \\\hline
\end{tabular}
\end{table}
\end{document}
更新
也许我无法实现解决方案,因为某些包之间存在冲突。这是我的序言,Typeset Engine 是pdfLaTeX
:
\documentclass[12pt,a4paper]{article}
%\usepackage{polyglossia}
%\setdefaultlanguage[babelshorthands]{spanish}
%\usepackage[Ligatures=TeX]{fontspec}
\usepackage[spanish,es-noshorthands]{babel}
\usepackage[T1]{fontenc}%http://tex.stackexchange.com/questions/44694/fontenc-vs-inputenc
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}%http://tex.stackexchange.com/questions/669/how-do-i-make-my-document-use-the-times-font-both-for-the-text-and-the-math
%\fontspec{Times New Roman}
%\usepackage{fontspec}
%\setmainfont{Times New Roman}
%\usepackage[T1]{fontenc}
%\usepackage{ifthen}
%\usepackage{fontspec}
%\setmainfont{Arial}
\usepackage[table]{xcolor}
%\usepackage[htt]{hyphenat}
%
%\usepackage{pdflscape}
%\usepackage[title]{appendix}
\usepackage[style=apa]{biblatex}
\addbibresource{bibltarea6.bib}
%\usepackage{array,multirow}
\usepackage{makecell}
\renewcommand\theadfont{\normalsize\bfseries}
\renewcommand\theadgape{}
\usepackage[math]{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\usepackage{listings}
\lstset{
basicstyle = \ttfamily,
keywordstyle= \color{blue}\textbf,
commentstyle= \color{gray},
stringstyle= \color{green!70!black},
stringstyle= \color{red},
columns= fullflexible,
numbers= left,
numberstyle= \scriptsize\sffamily\color{gray},
xleftmargin= 0.07\textwidth,
xrightmargin= 0.05\textwidth,
showstringspaces = false,
}
%\usepackage{inconsolata}
%\newcommand{\Cpp}{C\texttt{++}}
%\renewcommand{\lstlistingname}{Código}
%\renewcommand{\lstlistlistingname}{Índice de códigos}
%\usepackage{tikz}
%\usepgflibrary{arrows.meta}
%\tikzset{%
% newTip/.tip={Bar[sep=-1.45pt, width=10pt] Circle[sep=-1.25pt,width=2.5pt,length=2.5pt]}
% }
%\usetikzlibrary{patterns}
%
%\usepackage{tikz}
%\usepgflibrary{arrows.meta,shapes.arrows}
%\tikzset{%
% newTip/.tip={Bar[sep=-1.45pt, width=10pt] Circle[sep=-1.25pt,width=2.5pt,length=2.5pt]}
% }
%\usetikzlibrary{patterns}
%\usetikzlibrary{calc}
%\usepackage{caption}
%\usepackage{subcaption}
\usepackage{amsmath}
\usepackage{mathtools}
%\setcounter{MaxMatrixCols}{25}
\usepackage{siunitx}
\sisetup{per-mode = symbol}
%\usepackage{pgfplots}
%\newcounter{myrow}
%\usepackage{longtable}
%\usepackage{threeparttable}
%\usepackage[inline]{enumitem}
%\usepackage{hyperref}
\usepackage{titlesec}
\titleformat*{\section}{\bfseries\normalsize}
\titleformat*{\subsection}{\bfseries\normalsize}
\titleformat*{\subsubsection}{\bfseries\normalsize}
\usepackage[ampersand]{easylist}
%\usepackage{layout}
\usepackage{color,colortbl,hhline}
\definecolor{Gray}{gray}{0.9}
%\usepackage[a4paper,left=3cm, top=3cm, right=2.5cm, bottom=2.5cm]{geometry}
\setlength{\hoffset}{.46cm}
\setlength{\oddsidemargin}{13.08pt}
\setlength{\evensidemargin}{0cm}
\setlength{\marginparwidth}{0cm}
\setlength{\topmargin}{-7mm}
\setlength{\marginparsep}{0cm}
\setlength{\headheight}{8mm}
\setlength{\headsep}{4.6mm}
\setlength{\textheight}{24cm}
\setlength{\footskip}{8mm}
\setlength{\textwidth}{15.5cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{\footnotesize{Pontificia Universidad Católica del Perú}\\ \footnotesize{Escuela de Posgrado - Ingeniería Civil}}%Significa que est
\chead{}%Vac
\rhead{\footnotesize{Dinámica de Estructuras\\ Tarea 1}}
\lfoot{\footnotesize{}}%Pie izquierdo
\cfoot{\thepage}
\rfoot{\footnotesize{Fernández Yopla, Isai}}
\renewcommand{\headrulewidth}{0.4pt}%Falta investigar
\renewcommand{\footrulewidth}{0.4pt}
\usepackage[pass]{geometry}%pass tells output driver which paper size use.
答案1
第二行/列中的方程太长了。您需要将其分成两行。例如,使用aligned
包中的环境mathtools
。为了获得更多的垂直空间,您应该使用S
中的列说明符cellspace
。例如对于第二列S{p{12cm}}
::
编辑:
- 在某些情况下,当
siunitx
使用包时,包S
中的说明符cellspace
必须替换为C
,即C{p(12cm)}
- 在下面的 mwe 中我仅考虑与表相关的包
- 离题:由于您也使用该
geometry
包,因此您可以使用它来定义页面布局,并删除序言中的所有其他低级页面布局定义
\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}%http://tex.stackexchange.com/questions/44694/fontenc-vs-inputenc
\usepackage[utf8]{inputenc}
\usepackage[spanish,es-noshorthands]{babel}
\usepackage{mathptmx}%http://tex.stackexchange.com/questions/669/how-do-i-make-my-document-use-the-times-font-both-for-the-text-and-the-math
\usepackage{makecell,hhline} % <---
\renewcommand\theadfont{\normalsize\bfseries}
\renewcommand\theadgape{}
\usepackage{cellspace} % <---
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\usepackage{mathtools} % it load "amsmath" too
\usepackage{siunitx} % <--- used it, the "S" from the "cellspace# package
% had to be replaced with "C"
\usepackage[table]{xcolor} % <---
\definecolor{Gray}{gray}{0.9}
\usepackage{geometry} % for simple determination of page layout.
% see its documentation!
\begin{document}
\begin{table}[htpb]
\centering
\caption{Solución de la ecuación }
\begin{tabular}{|p{1cm}|C{p{12cm}}|}
\hline
\rowcolor{Gray}
\thead{Caso} & \thead{Solución} \\
\hline
$\zeta = 1$ & $u(t) = \bigl[u(0) + \bigl(\dot{u}(0) + u(0) \omega_n\bigr) t\bigr] e^{-\omega_n t}$ \\ \hline
$\zeta > 1$ & $\begin{multlined}
u(t) = \dfrac{e^{-\omega_n\zeta}}{2\omega_n\sqrt{\zeta^2-1}}
\biggl\{\Bigl[\omega_n\Bigl(\zeta+\sqrt{\zeta^2-1}\Bigr)u(0)+\dot{u}(0)\Bigr] e^{\omega_n\sqrt{\zeta^2-1}} - \\
\Bigl[\omega_n\Bigl(\zeta - \sqrt{\zeta^2-1}\Bigr)u(0)+\dot{u}(0)\Bigr] e^{-\omega_n\sqrt{\zeta^2-1}}
\biggr\}
\end{multlined}$ \\ \hline
$\zeta < 1$ & $u(t) = e^{-\omega_n\zeta t}
\biggl[u(0)\cos{\omega_Dt} +
\biggl(\dfrac{\dot{u}(0) + \omega_n\zeta u(0)}{\omega_D}\biggr)
\biggr]$ \\ \hline
\end{tabular}
\end{table}
\end{document}
答案2
正如@Zarko 已经指出的那样他的回答,主要问题是其中一个主要方程太长,无法放在一行中。使用aligned
环境引入适当选择的换行符。
一旦您对长方程式进行了换行,就不需要使用列类型;相反,只需对两列p
使用基本列类型。l
为了使表格材料更加整洁,我会u(t) =
从单元格中删除重复的部分,然后将这些信息粘贴到表格的标题中。
我还想建议您让表格看起来更加开放,主要是通过删除所有垂直和水平黑线——它们根本就不需要。我还会加载包booktabs
并使用其\addlinespace
宏来进一步增加行之间的空白。
此外,我会用明确的尺寸说明替换所有指令\left
。\right
\documentclass[12pt,a4paper]{article}
\usepackage[spanish]{babel} % new
\usepackage{array}
\usepackage{booktabs} % for "\addlinespace" macro
\usepackage[table]{xcolor}
\definecolor{Gray}{gray}{0.9}
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage{amsmath} % for 'aligned' environment
\begin{document}
\begin{table}[htpb]
\setlength\extrarowheight{3pt}
\centering
\caption{Solución de la ecuación por $u(t)$}
\begin{tabular}{ll}
\rowcolor{Gray} \textbf{Caso} & \textbf{Solución } \\
\addlinespace
$\zeta = 1$ &
$\displaystyle
\bigl[u(0) + (\dot u(0) + u(0) \omega_n )t\bigr]
e^{-\omega_n t}
$\\ \addlinespace
$\zeta > 1$ &
$\begin{aligned}[t]
\frac{e^{-\omega_n\zeta}}{2\omega_n\sqrt{\zeta^2-1}}\Bigl\lbrace
&\bigr[\omega_n(\zeta+\sqrt{\zeta^2-1})u(0)+\dot u(0)\bigr]
e^{\omega_n\sqrt{\zeta^2-1}}\\
-&\bigl[\omega_n(\zeta - \sqrt{\zeta^2-1})u(0)+\dot u(0)\bigr]
e^{-\omega_n\sqrt{\zeta^2-1}}\,
\Bigr\rbrace
\end{aligned}$ \\ \addlinespace
$\zeta < 1$ &
$\displaystyle
e^{-\omega_n\zeta t}\bigl[u(0)\cos{\omega_Dt}
+ \bigl(\dot u(0) + \omega_n\zeta u(0)\bigr)\big/\omega_D
\bigr]$ \\
\end{tabular}
\end{table}
\end{document}