我有这个简单的代码:我可以以横向方式构建表格,但是当我插入命令adjustbox时,出现一些错误:不在外部模式中未定义的控制序列...
错误包图形除以 0。
\begin{landscape}
\begin{adjustbox}{width=\textheight,totalheight=\textwidth,keepaspectratio}
\begin{table}
\centering\small
\caption{Summary of analytical expression for $\textrm{PFD}_\textrm{avg}$ Calculations} \label{Summary}
\begin{tabular}{lcccc}
\toprule
\textrm{Analytical Expression} & FPT & FPT with \emph{p}PPT & FPT with \emph{np}PPT & Comments \\
\cmidrule{1-5}
IEC-61508-6 & $ \binom{n}{n-k+1} \lambda_D^{n-k+1} \tau^{n-k} \cdot \frac{\lambda_{DU}}{\lambda_{D}}$ & $\binom{n}{n-k+1} \lambda_D^{n-k+1} \tau^{n-k} \cdot \frac{(TCF)\lambda_{DU}}{\lambda_D}\left(\frac{\tau}{n-k+2}+MRT\right)$ & & \\
&$\left(\frac{\tau}{n-k+2} +MRT\right)+\frac{\lambda_{DD}}{\lambda_{D}}(MTTR) $ & $ +\frac{(1-TCF)\lambda_{DU}}{\lambda_D}\left(\frac{\tau_{OH}}{n-k+2}+MRT\right)+\frac{\lambda_{DD}}{\lambda_D}MTTR $ & & \\
Simplified & $\binom{n}{n-k+1}\frac{(\lambda_{DU}\tau)^{n-k+1}}{n-k+2}$ & & & \\
Formulas & & & & \\
Non-Approximate& $1-\sum_{x=k}^n \left[S(k,n,x) \cdot \frac{1-e^{-x \cdot \lambda \cdot \tau}}{x \cdot \lambda \cdot \tau} \right]$& $1-$ & $1-$ & $S(k,n,x) = \sum_{y=k}^n \left[\binom{n}{x} \cdot \binom{x}{y} \cdot (-1)^{x-y}\right] $ \\
Equations & & $\sum_{x=k}^n \left[S(k,n,x).\frac{1-e^{-x\lambda t_{TD}}}{x\lambda t_{TD}}.\frac{1}{m}.\sum_{i=1}^m\left(e^{-x(1-E)\lambda(i-1)t_{TD}}\right)\right]$&$\sum_{x=k}^n \left[S(k,n,x) \cdot \sum_{i=1}^m \left( e^{x \cdot (1-TCF) \cdot \lambda \cdot t_{i-1}} \cdot \frac{1-e^{-x \cdot \lambda \cdot t_{TDi}}}{x \cdot \lambda \cdot \tau} \right) \right]$ &$ \hspace{5 mm}\textrm{for} \hspace{3 mm} x=k,...,n$ \\
$\Delta$-Testing & $ \frac{n!(\lambda_{DU} \tau)^{n-k+1}}{(n-k+2)!(k-1)!}$ & $\frac{1}{m} \sum_{i=1}^m \sum_{j=0}^{n-k} \binom{n}{j} ((i-1)\lambda_b t_{TD} )^j \frac{(n-j)!(\lambda t_{TD})^{n-j-k+1}}{(n-j-k+2)!(k-1)!} $ & & \\
& & $+ \frac{1}{m} \sum_{i=1}^m \sum_{j=n-k+1}^{n} \binom{n}{j} ((i-1)\lambda_b t_{TD})^j$& & \\
Policy & & & & \\
\bottomrule
\end{tabular}
\end{table}
\end{adjustbox}
\end{landscape}
答案1
我认为您不需要该adjustbox
包及其同名环境来排版您的表格。相反,我会使用包\resizebox{}{}{...}
的命令graphicx
。如果您将其设置!
为命令的第二个参数\resizebox
,则对象的纵横比将自动保留。
另外,我建议您使用包sidewaystable
的环境rotating
,而不是使用单独的嵌套landscape
环境table
。而且,由于表格的宽度将缩小到(旋转的)文本块的宽度,因此无需提供或\centering
指令\small
。不过,我会使用诸如\renewcommand\arraystretch{2}
增加行之间的间隔的指令。
\documentclass{article}
\usepackage{rotating,amsmath,booktabs,graphicx}
\begin{document}
\begin{sidewaystable}
\caption{Summary of analytical expression for $\textrm{PFD}_\textrm{avg}$ Calculations}
\label{Summary}
\renewcommand\arraystretch{2} % increase spacing between rows
\resizebox{\textwidth}{!}{%
\begin{tabular}{lcccc}
\toprule
\textrm{Analytical Expression} & FPT & FPT with \emph{p}PPT & FPT with \emph{np}PPT & Comments \\
\midrule{1-5}
% < Body of tabular environment >
\bottomrule
\end{tabular}} % end of scope of \resizebox
\end{sidewaystable}
\end{document}
附录:正如您在评论中指出的那样,将表格放入可用空间中看起来并不“美观”,因为生成的字体大小相当小。主要原因是各个单元格中的公式非常宽。我尝试通过选择不同的换行符来改善表格的外观。我还做了一些其他更改,这些更改加在一起也有助于使表格看起来更美观。例如,我为变量名称选择了直立罗马字体,并允许在第一列中换行。为了使现在跨行的数学表达式保持美观和紧凑,我将它们放在单独的array
环境中。当然,您可以根据需要更改所有这些。
\documentclass{article}
\usepackage{array,rotating,amsmath,booktabs,graphicx}
\usepackage[margin=1in]{geometry}
% Define appearance of variable names, say, \textnormal
\newcommand{\V}[1]{\textnormal{#1}}
\newcommand\TCF{\V{TCF}}
\newcommand\MRT{\V{MRT}}
\newcommand\MTTR{\V{MTTR}}
\newcommand\DD{\V{DD}}
\newcommand\DU{\V{DU}}
\newcommand\OH{\V{OH}}
\newcommand\TD{\V{TD}}
\begin{document}
\begin{sidewaystable}
\caption{Summary of analytical expression for $\textrm{PFD}_\textrm{avg}$ Calculations}
\label{Summary}
\resizebox{\textwidth}{!}{$ %start math mode as we're using "array" environment
\begin{array}{@{} >{\raggedright}p{2.8cm} llll @{}}
\toprule
\textnormal{Analytical Expression} &
\textnormal{FPT} & \textnormal{FPT with \emph{p}PPT} &
\textnormal{FPT with \emph{np}PPT} & \textnormal{Comments} \\
\midrule{1-5}
\textnormal{IEC-61508-6} &
\binom{n}{n-k+1} \lambda_D^{n-k+1} \tau^{n-k} \frac{\lambda_{\DU}}{\lambda_{D}} &
\binom{n}{n-k+1} \lambda_D^{n-k+1} \tau^{n-k} \frac{(\TCF)\lambda_{\DU}}{\lambda_D}
\left(\frac{\tau}{n-k+2}+\MRT\right)\\
& \left(\frac{\tau}{n-k+2} +\MRT\right)
+\frac{\lambda_{\DD}}{\lambda_{D}}(\MTTR) &
\quad {}+\frac{(1-\TCF)\lambda_{\DU}}{\lambda_D}
\left(\frac{\tau_{\OH}}{n-k+2}+\MRT\right)
+\frac{\lambda_{\DD}}{\lambda_D}\MTTR \\ \addlinespace
\textnormal{Simplified Formulas} &
\binom{n}{n-k+1}\frac{(\lambda_{\DU}\tau)^{n-k+1}}{n-k+2} \\ \addlinespace
\textnormal{Non-Approximate Equations} &
1-\sum_{x=k}^n \left[S(k,n,x) \frac{1-e^{-x \lambda \tau}}{x \lambda \tau} \right]&
\begin{array}[t]{@{}l@{}}
1-\sum_{x=k}^n \Bigl[S(k,n,x)\frac{1-e^{-x\lambda t_{\TD}}}{x\lambda t_{\TD}}\\
\quad\times \frac{1}{m}\sum_{i=1}^m\left(e^{-x(1-E)\lambda(i-1)t_{\TD}}\right)\Bigr]
\end{array} &
\begin{array}[t]{@{}l@{}}
1-\sum_{x=k}^n \Bigl[S(k,n,x)\\
\quad\times\sum_{i=1}^m \left( e^{(x (1-\TCF) \lambda t_{i-1})} \,
\frac{1-e^{-x \lambda t_{\TD i}}}{x \lambda \tau} \right) \Bigr]
\end{array} &
\begin{array}[t]{@{}l@{}}
S(k,n,x) = \sum_{y=k}^n \left[\binom{n}{x} \binom{x}{y} (-1)^{x-y}\right] \\
\quad\text{for $x=k,\dots,n$}
\end{array} \\
\addlinespace
\textnormal{$\Delta$-Testing Policy} &
\frac{n!(\lambda_{\DU} \tau)^{n-k+1}}{(n-k+2)!(k-1)!} &
\begin{array}[t]{@{}l@{}}
\frac{1}{m} \sum_{i=1}^m \sum_{j=0}^{n-k} \binom{n}{j} \Bigl[\bigl((i-1)\lambda_b t_{\TD} \bigr)^j \\
\qquad \times \frac{(n-j)!(\lambda t_{\TD})^{n-j-k+1}}{(n-j-k+2)!(k-1)!}\Bigr] \\
\quad{}+\frac{1}{m} \sum_{i=1}^m \sum_{j=n-k+1}^{n} \binom{n}{j} \bigl((i-1)\lambda_b t_{\TD}\bigr)^j
\end{array} \\
\bottomrule
\end{array} $} % end of scope of \resizebox
\end{sidewaystable}
\end{document}
答案2
你不能用这种方式把浮点数放入盒子里,也就是说,你需要把table
环境外部的adjustbox
,不在里面!您也可以直接添加float=table
到调整框键,如下所示。
请注意,像表格中这样缩放文本不是一个好主意,因为字体不是为缩放而设计的。参见为什么不缩放包含文本的元素更多细节。
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{adjustbox}
\begin{document}
\begin{adjustbox}{width=\textheight-2\baselineskip,totalheight=\textwidth,keepaspectratio,rotate=90,center,
caption={Summary of analytical expression for $\textrm{PFD}_\textrm{avg}$ Calculations}, label={Summary},
float=table}
\small
\begin{tabular}{lcccc}
\toprule
\textrm{Analytical Expression} & FPT & FPT with \emph{p}PPT & FPT with \emph{np}PPT & Comments \\
\cmidrule{1-5}
IEC-61508-6 & $ \binom{n}{n-k+1} \lambda_D^{n-k+1} \tau^{n-k} \cdot \frac{\lambda_{DU}}{\lambda_{D}}$ & $\binom{n}{n-k+1} \lambda_D^{n-k+1} \tau^{n-k} \cdot \frac{(TCF)\lambda_{DU}}{\lambda_D}\left(\frac{\tau}{n-k+2}+MRT\right)$ & & \\
&$\left(\frac{\tau}{n-k+2} +MRT\right)+\frac{\lambda_{DD}}{\lambda_{D}}(MTTR) $ & $ +\frac{(1-TCF)\lambda_{DU}}{\lambda_D}\left(\frac{\tau_{OH}}{n-k+2}+MRT\right)+\frac{\lambda_{DD}}{\lambda_D}MTTR $ & & \\
Simplified & $\binom{n}{n-k+1}\frac{(\lambda_{DU}\tau)^{n-k+1}}{n-k+2}$ & & & \\
Formulas & & & & \\
Non-Approximate& $1-\sum_{x=k}^n \left[S(k,n,x) \cdot \frac{1-e^{-x \cdot \lambda \cdot \tau}}{x \cdot \lambda \cdot \tau} \right]$& $1-$ & $1-$ & $S(k,n,x) = \sum_{y=k}^n \left[\binom{n}{x} \cdot \binom{x}{y} \cdot (-1)^{x-y}\right] $ \\
Equations & & $\sum_{x=k}^n \left[S(k,n,x).\frac{1-e^{-x\lambda t_{TD}}}{x\lambda t_{TD}}.\frac{1}{m}.\sum_{i=1}^m\left(e^{-x(1-E)\lambda(i-1)t_{TD}}\right)\right]$&$\sum_{x=k}^n \left[S(k,n,x) \cdot \sum_{i=1}^m \left( e^{x \cdot (1-TCF) \cdot \lambda \cdot t_{i-1}} \cdot \frac{1-e^{-x \cdot \lambda \cdot t_{TDi}}}{x \cdot \lambda \cdot \tau} \right) \right]$ &$ \hspace{5 mm}\textrm{for} \hspace{3 mm} x=k,...,n$ \\
$\Delta$-Testing & $ \frac{n!(\lambda_{DU} \tau)^{n-k+1}}{(n-k+2)!(k-1)!}$ & $\frac{1}{m} \sum_{i=1}^m \sum_{j=0}^{n-k} \binom{n}{j} ((i-1)\lambda_b t_{TD} )^j \frac{(n-j)!(\lambda t_{TD})^{n-j-k+1}}{(n-j-k+2)!(k-1)!} $ & & \\
& & $+ \frac{1}{m} \sum_{i=1}^m \sum_{j=n-k+1}^{n} \binom{n}{j} ((i-1)\lambda_b t_{TD})^j$& & \\
Policy & & & & \\
\bottomrule
\end{tabular}
\end{adjustbox}
\end{document}