[Tex/LaTex] How to fit a wide table landscape orientation

adjustbox

I have this simple code: I can build the table on landscape orientation, but when I insert the command adjustbox, there are some erros:
Not in outer par mode
undefined conttrol sequence

Error package graphics division by 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}

Best Answer

I don't think you need the adjustbox package and its eponymous environment to typeset your table. I would, instead, use the \resizebox{}{}{...} command of the graphicx package. If you set ! as the second argument of the \resizebox command, the object's aspect ratio will be preserved automatically.

Separately, I would recommend that you employ the sidewaystable environment of the rotating package instead of using separate, nested landscape and table environments. And, since the width of the table is going to be reduced to that of the (rotated) text block, there's no need to provide either a \centering or a \small instruction. I would, though, use an instruction such as \renewcommand\arraystretch{2} to increase the separation between the rows.

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

Addendum: As you've noted in a comment, fitting your table into the available space doesn't look "nice", as the resulting font size is rather small. The main culprit is the formulas in the various cells are very wide. I've taken a stab at improving the look of the table by choosing different line breaks. I've also made a few more changes which, taken together, also contribute to a nicer-looking table. E.g., I've chosen an upright roman font for the variable names, and I allow line breaks in the first column. To keep the math expressions that are now broken across lines nice and compact, I've placed them in separate array environment. You can change all this, of course, to suit your needs.

enter image description here

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