Information and discussion about graphics, figures & tables in LaTeX documents.
Tobias_Denmark
Posts: 18 Joined: Sun Jun 06, 2010 1:59 pm
Post
by Tobias_Denmark » Mon Jun 23, 2014 5:15 pm
Hi. Can not get the sidewaystable to fit the textwidth (or linewidth). Have also tried with textheight. I have added "showframe" to geometry to show you the error.
Code: Select all
\documentclass[a4paper,10pt]{book}
\usepackage[showframe,margin=3cm]{geometry}
\usepackage{adjustbox}
\usepackage{booktabs,array}
\usepackage[font=small,labelfont=bf]{caption}
\captionsetup[table]{position=top,skip=7pt}
\usepackage{rotating}
\renewcommand{\arraystretch}{1.2}
\begin{document}
\begin{sidewaystable}
\centering
\caption{TEST TEST TEST.}
\label{tab:ex}
\begin{adjustbox}{max width=\textwidth,max totalheight=\textheight,keepaspectratio}
\begin{tabular}{ccccccccccccc}
\hline
&&&&&& Initial & Reference & Resulting & Grain & Bulk && Grain\\
Plug & Length & Diameter & Weight & V2 & V3 & Pressure & Pressure & Pressure & Volume & Volume & Porosity & Density\\
\small{no.} & \small{cm} & \small{cm} & \small{g} & \small{on/off} & \small{on/off} & \small{psig} & \small{psig} & \small{psig} & \small{cm$^3$} & \small{cm$^3$} & \small{\%} & \small{g/cm$^3$}\\
\hline
1D & 4.5578 & 3.8150 & ~76.4758 & on & on & 0.14 & 103.35 & 20.92 & 28.357 & 52.100 & 45.57 & 2.697 \\
&&&&&&& 103.31 & 20.91 &&&& \\
&&&&&&& 103.27 & 20.90 &&&& \\
2D & 6.0548 & 3.8305 & 109.8275 & on & on & 0.14 & 102.99 & 24.25 & 40.902 & 69.776 & 41.38 & 2.685 \\
&&&&&&& 102.99 & 24.28 &&&& \\
&&&&&&& 102.97 & 24.28 &&&& \\
4D & 5.7680 & 3.8193 & 118.1769 & on & on & 0.14 & 102.77 & 24.78 & 42.612 & 66.083 & 35.52 & 2.773 \\
&&&&&&& 102.73 & 24.76 &&&& \\
&&&&&&& 102.74 & 24.77 &&&& \\
5D & 6.1712 & 3.8437 & 103.6808 & on & on & 0.13 & 102.54 & 23.24 & 37.905 & 71.606 & 47.06 & 2.735 \\
&&&&&&& 102.54 & 23.25 &&&& \\
&&&&&&& 102.57 & 23.25 &&&& \\
8D & 6.0173 & 2.4363 & ~43.8543 & off & on & 0.14 & 102.44 & 35.02 & 16.174 & 28.052 & 42.34 & 2.711 \\
&&&&&&& 102.43 & 35.02 &&&& \\
&&&&&&& 102.44 & 35.04 &&&& \\
9D & 5.8937 & 2.4190 & ~40.6715 & off & on & 0.14 & 102.39 & 33.96 & 14.879 & 27.086 & 45.07 & 2.734 \\
&&&&&&& 102.43 & 34.02 &&&& \\
&&&&&&& 102.44 & 34.03 &&&& \\
11D & 6.0962 & 2.4535 & ~50.4501 & off & on & 0.13 & 102.32 & 37.10 & 18.622 & 28.822 & 35.39 & 2.709 \\
&&&&&&& 102.41 & 37.11 &&&& \\
&&&&&&& 102.32 & 37.06 &&&& \\
16D & 5.0287 & 2.4205 & ~37.0499 & off & on & 0.14 & 102.36 & 32.91 & 13.483 & 23.139 & 41.73 & 2.748 \\
&&&&&&& 102.34 & 32.99 &&&& \\
&&&&&&& 102.36 & 32.95 &&&& \\
17D & 6.3023 & 3.8210 & 140.4300 & on & on & 0.14 & 102.52 & 28.22 & 51.879 & 72.268 & 28.21 & 2.707 \\
&&&&&&& 102.51 & 28.22 &&&& \\
&&&&&&& 102.48 & 28.23 &&&& \\
\hline
\end{tabular}
\end{adjustbox}
\end{sidewaystable}
\end{document}
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Johannes_B
Site Moderator
Posts: 4182 Joined: Thu Nov 01, 2012 4:08 pm
Post
by Johannes_B » Mon Jun 23, 2014 5:38 pm
The quickest workaround coming to my head (without even looking at the code) would be max width=.8\textwidth
.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Tobias_Denmark
Posts: 18 Joined: Sun Jun 06, 2010 1:59 pm
Post
by Tobias_Denmark » Tue Jun 24, 2014 9:20 am
Hi Johannes,
Yes, of course one can use that workaround
That has also been my solution until now. I just thought that there must be some mistake in my code or errors in the packages, since the max width is not set as what was expected.
Johannes_B
Site Moderator
Posts: 4182 Joined: Thu Nov 01, 2012 4:08 pm
Post
by Johannes_B » Wed Jun 25, 2014 3:32 pm
It seems that the sidewaystable changes the lengths of textwidth and heigth.
When saving those before rotating and using them everything works fine.
Code: Select all
\documentclass[a4paper,10pt]{book}
\usepackage[showframe,margin=3cm]{geometry}
\usepackage{adjustbox}
\usepackage{booktabs,array}
\usepackage[font=small,labelfont=bf]{caption}
\captionsetup[table]{position=top,skip=7pt}
\usepackage{rotating}
\renewcommand{\arraystretch}{1.2}
\begin{document}
\newlength{\testerA}
\newlength{\testerB}
\setlength{\testerA}{\textwidth}
\setlength{\testerB}{\textheight}
\begin{sidewaystable}
\centering
\caption{TEST TEST TEST.}
\label{tab:ex}
\begin{adjustbox}{max totalsize={\testerB}{\testerA}}
\begin{tabular}{ccccccccccccc}
\hline
&&&&&& Initial & Reference & Resulting & Grain & Bulk && Grain\\
Plug & Length & Diameter & Weight & V2 & V3 & Pressure & Pressure & Pressure & Volume & Volume & Porosity & Density\\
\small{no.} & \small{cm} & \small{cm} & \small{g} & \small{on/off} & \small{on/off} & \small{psig} & \small{psig} & \small{psig} & \small{cm$^3$} & \small{cm$^3$} & \small{\%} & \small{g/cm$^3$}\\
\hline
1D & 4.5578 & 3.8150 & ~76.4758 & on & on & 0.14 & 103.35 & 20.92 & 28.357 & 52.100 & 45.57 & 2.697 \\
&&&&&&& 103.31 & 20.91 &&&& \\
&&&&&&& 103.27 & 20.90 &&&& \\
2D & 6.0548 & 3.8305 & 109.8275 & on & on & 0.14 & 102.99 & 24.25 & 40.902 & 69.776 & 41.38 & 2.685 \\
&&&&&&& 102.99 & 24.28 &&&& \\
&&&&&&& 102.97 & 24.28 &&&& \\
4D & 5.7680 & 3.8193 & 118.1769 & on & on & 0.14 & 102.77 & 24.78 & 42.612 & 66.083 & 35.52 & 2.773 \\
&&&&&&& 102.73 & 24.76 &&&& \\
&&&&&&& 102.74 & 24.77 &&&& \\
5D & 6.1712 & 3.8437 & 103.6808 & on & on & 0.13 & 102.54 & 23.24 & 37.905 & 71.606 & 47.06 & 2.735 \\
&&&&&&& 102.54 & 23.25 &&&& \\
&&&&&&& 102.57 & 23.25 &&&& \\
8D & 6.0173 & 2.4363 & ~43.8543 & off & on & 0.14 & 102.44 & 35.02 & 16.174 & 28.052 & 42.34 & 2.711 \\
&&&&&&& 102.43 & 35.02 &&&& \\
&&&&&&& 102.44 & 35.04 &&&& \\
9D & 5.8937 & 2.4190 & ~40.6715 & off & on & 0.14 & 102.39 & 33.96 & 14.879 & 27.086 & 45.07 & 2.734 \\
&&&&&&& 102.43 & 34.02 &&&& \\
&&&&&&& 102.44 & 34.03 &&&& \\
11D & 6.0962 & 2.4535 & ~50.4501 & off & on & 0.13 & 102.32 & 37.10 & 18.622 & 28.822 & 35.39 & 2.709 \\
&&&&&&& 102.41 & 37.11 &&&& \\
&&&&&&& 102.32 & 37.06 &&&& \\
16D & 5.0287 & 2.4205 & ~37.0499 & off & on & 0.14 & 102.36 & 32.91 & 13.483 & 23.139 & 41.73 & 2.748 \\
&&&&&&& 102.34 & 32.99 &&&& \\
&&&&&&& 102.36 & 32.95 &&&& \\
17D & 6.3023 & 3.8210 & 140.4300 & on & on & 0.14 & 102.52 & 28.22 & 51.879 & 72.268 & 28.21 & 2.707 \\
&&&&&&& 102.51 & 28.22 &&&& \\
&&&&&&& 102.48 & 28.23 &&&& \\
17D & 6.3023 & 3.8210 & 140.4300 & on & on & 0.14 & 102.52 & 28.22 & 51.879 & 72.268 & 28.21 & 2.707 \\
&&&&&&& 102.51 & 28.22 &&&& \\
&&&&&&& 102.48 & 28.23 &&&& \\
\hline
\end{tabular}
\end{adjustbox}
\end{sidewaystable}
\end{document}
Please note, that the whole thing still sticks out into the margin, cause the caption is outside the adjustbox.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.