我需要创建一个这样的表格:
以下是我目前所掌握的信息:
\usepackage{graphicx}
\usepackage{array}
\newcolumntype{N}{>{\footnotesize}p{2.5cm}}
...
\begin{center}
\normalsize
\makebox[1 \textwidth][c]{
\resizebox{1.3 \textwidth}{!}{
{\renewcommand{\arraystretch}{2}%
\begin{tabular}{|lll|N|}
\hline
Planck's function & $B_{\nu}(T)=\frac{2h\nu^{3}}{c^2}{\,}\frac{1}{e^{h\nu / kT}-1}$ & (1.1) & placeholder\\ \cline{1-3}
d & c & b & a
\end{tabular}}}}
\end{center}
这给了我这个:
我希望最后一列像第一张图片那样压缩。我尝试使用多行,但不知道该如何构造它。
答案1
像这样吗?
\documentclass{article}
\usepackage{graphicx}
\usepackage{tabularx}
\newcolumntype{L}{>{$\displaystyle}X<{$}}
\newcolumntype{N}{>{\footnotesize}p{3cm}}
\newlength\PlanckLength % ouch!
\settowidth{\PlanckLength}{Planck's}
\newcommand\mytab[1]{%
\begingroup
\renewcommand\arraystretch{1}
\setlength\extrarowheight{1pt}
\begin{tabular}{@{} % width of 2nd column is a residual
>{$}wl{2.5mm}<{$}
>{\raggedright\arraybackslash}m{\dimexpr\linewidth-2.5mm-2\tabcolsep\relax}@{}}
#1
\end{tabular}%
\endgroup}
\begin{document}
\begin{center}
\normalsize % are you sure you need this?
\renewcommand{\arraystretch}{2}
\begin{tabularx}{\textwidth}{| >{\raggedright}m{\PlanckLength} L r | N|}
\hline
Planck's function &
B_{\nu}(T)=\frac{2h\nu^{3}}{c^2}{\,}\frac{1}{\exp(h\nu / kT)-1} &
(1.1) &
\mytab{ \alpha & right ascension of date \\
\alpha_0 & right ascension at J2000.0 \\
N & number of years since J2000.0} \\
\cline{1-3}
a & b & c & d \\
\hline
\end{tabularx}
\end{center}
\end{document}
附录回答 OP 的后续问题:如果需要的是 (a) 自动方程编号和 (b) 在需要时在方程中引入换行符的方法,我建议您 (i) 将环境布局从四列切换到三列,tabularx
以及 (ii) 根据需要使用包中的一些显示数学环境amsmath
,例如align
、gather
和multline
,以排版(可能是多行)方程和相关的方程编号。
\documentclass{article}
\usepackage{amsmath,tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\newcolumntype{N}{>{\footnotesize}p{3cm}}
\newlength\PlanckLength % ouch!
\settowidth{\PlanckLength}{Planck's} % width of 1st column
\counterwithin{equation}{section} % just for this example
\newcommand\mytab[1]{%
\begingroup
\renewcommand\arraystretch{1}
\setlength\extrarowheight{1pt} % for a less cramped "look"
\setlength\tabcolsep{4pt} % default: 6pt
\begin{tabular}{@{}
>{$}wl{2.5mm}<{$}
>{\raggedright\arraybackslash}m{\dimexpr\linewidth-2.5mm-2\tabcolsep\relax}
@{}}
#1
\end{tabular}%
\endgroup}
\begin{document}
\stepcounter{section} % just for this example
\begin{center}
\normalsize % are you sure you need this?
\renewcommand{\arraystretch}{2}
\begin{tabularx}{\textwidth}{|
>{\raggedright\arraybackslash}p{\PlanckLength}
>{\centering\arraybackslash}X |
N |}
\hline
Planck's function &
\begin{equation}
B_{\nu}(T)=\frac{2h\nu^{3}}{c^2} \, \frac{1}{\exp(h\nu/( kT))-1}
\end{equation}
&
\mytab{ \alpha & right ascension of date \\
\alpha_0 & right ascension at J2000.0 \\
N & number of years since J2000.0} \\
\cline{1-2}
a & b & c \\
\hline
\end{tabularx}
\end{center}
\end{document}
答案2
这是我的尝试tabularray
(这是我第一次使用这个包……)。
\documentclass{article}
\usepackage{tabularray}
\usepackage{lipsum}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{cleveref}
\begin{document}
\lipsum[1]
\begin{equation}
E_c=\frac{1}{2}MV^2
\label{eq:Ec}
\end{equation}
\begin{table}[!h]
\centering
\begin{tblr}{
width=\textwidth,
colspec={|t{6em}|X[1]l|lt{7em}|},
column{2}={mode=dmath},
column{4}={font=\footnotesize,mode=math,rightsep=1pt},
column{5}={font=\footnotesize,leftsep=0pt}
}
\hline
\SetCell[r=3]{m} Planck's function & \SetCell[r=3]{m} B_{\nu}(T)=\frac{2h\nu^{3}}{c^2}{\,}\frac{1}{e^{h\nu / kT}-1} & \SetCell[r=3]{m} \eqref{eq:Planck} & \alpha & right ascension of date \\
& & & \alpha_0 & right ascension at J2000.0 \\
& & & N & number of years since J2000.01\\
\cline{1-3}
a & b & & c & d\\
\cline{1-3}
\SetCell[r=2]{m} A very veeryy veeeryyy veeeeryyyy long name & \SetCell[r=2]{m} P=mg & \SetCell[r=2]{m} \eqref{eq:Pmg} & m & mass\\
& & & g & \qty{9.81}{\metre\per\second\squared}\\
\hline
\end{tblr}
\refstepcounter{equation}\label{eq:Planck}
\refstepcounter{equation}\label{eq:Pmg}
\end{table}
\Cref{eq:Ec} then \cref{eq:Planck} and last \cref{eq:Pmg}.
\lipsum[2]
\end{document}