# Alternative to adjustbox for table full page width

I have a few multi column csv tables I am importing with \csvreader. Some are smaller than page width (Table 1), others are larger (Table 2). I would like to make them all exactly the full page width (6.5in). Adjustbox seems to scale the text size, spacing, line weight, etc, which I would like to maintain constant, and just stretch the table with added space in columns. I would prefer if in Table 2 text is wrapped if possible rather than using smaller font.

\documentclass[10pt,letterpaper]{article}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{fontspec}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{parskip}
\usepackage[table]{xcolor}
\usepackage{sectsty}
\usepackage{titlesec}
\usepackage{float}
\usepackage[font=bf, skip=2pt]{caption}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{csvsimple}
\usepackage{datatool}
\usepackage[backend=bibtex8]{biblatex}

%Table 1
\usepackage{filecontents}
\begin{filecontents*}{file1.csv}
Timestamp, Fields, Issue
xxx,111,222
333,444,222
xxx,111,222
xxx,111,222
\end{filecontents*}

%Table 2
\usepackage{filecontents}
\begin{filecontents*}{file2.csv}
Timestamp, Fields, Issue
xxxxxxxx xxxxxxxxxxxx xxxxxxxx xxxxxxxxx xxxxxx xxxxxx,111111 11111 111111 1111111 1111 1111,222 2222222 22222 2222222 2222222
333,444,222
xxx,111,222
xxx,111,222
\end{filecontents*}

\begin{document}

%Table 1
\begin{table}[H]
\centering
\caption{\label{tab:screening}Data Periods Removed during Data Quality Assessment}
late after first line=\\,
late after line=\\\hline,
]%
{file1.csv}{}{%
\csvcoli & \csvcolii & \csvcoliii}
\end{table}

%Table 2
\begin{table}[H]
\centering
\caption{\label{tab:screening}Data Periods Removed during Data Quality Assessment}
late after first line=\\,
late after line=\\\hline,
]%
{file2.csv}{}{%
\csvcoli & \csvcolii & \csvcoliii
}

\end{table}

\end{document}

• Welcome! Normally one uses tabularx for that purpose. Whether or not this works in your example, I do not know because your example is not a compilable document. Please make it compilable such that it starts with \documentclass and ends with \end{document} to make it easier for others to help you.
– user194703
Nov 29, 2019 at 19:01
• Hi thanks, Ok I just made compilable! Nov 29, 2019 at 22:14
• Thanks! It seems that tabularx is not supported. You could use for the second table something like tabular=p{5cm}|>{\centering}p{4cm}|>{\centering\arraybackslash}p{4cm}. Of course, you could compute the precise lengths that make it precisely fit by doing some algebra with \tabcolsep and friends. Please indicate if you need a precise fit.
– user194703
Nov 29, 2019 at 22:44
• Thank you!! This will work for now. I can probably figure out the math but for future, it would be nice if it did the math automatically somehow. Any ideas? Nov 30, 2019 at 0:01
• The idea is called tabularx. However, according to what I find it does not get directly supported in cvsimple. Of course, one could try to hack it.
– user194703
Nov 30, 2019 at 0:03

I will be happy to remove this but you can just compute the distance.

\documentclass[10pt,letterpaper]{article}
\usepackage[letterpaper,margin=1in,showframe]{geometry}
\usepackage{fontspec}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{parskip}
\usepackage[table]{xcolor}
\usepackage[font=bf, skip=2pt]{caption}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{csvsimple}
\usepackage{datatool}
\usepackage{pgf}

%Table 1
\usepackage{filecontents}
\begin{filecontents*}{file1.csv}
Timestamp, Fields, Issue
xxx,111,222
333,444,222
xxx,111,222
xxx,111,222
\end{filecontents*}

%Table 2
\begin{filecontents*}{file2.csv}
Timestamp, Fields, Issue
xxxxxxxx xxxxxxxxxxxx xxxxxxxx xxxxxxxxx xxxxxx xxxxxx,111111 11111 111111 1111111 1111 1111,222 2222222 22222 2222222 2222222
333,444,222
xxx,111,222
xxx,111,222
\end{filecontents*}

\begin{document}

%Table 1
\begin{table}[htb]
\centering
\caption{\label{tab:screening}Data Periods Removed during Data Quality Assessment}
late after first line=\\,
late after line=\\\hline,
]%
{file1.csv}{}{%
\csvcoli & \csvcolii & \csvcoliii}
\end{table}

%Table 2
\begin{table}[htb]
\centering\pgfmathsetmacro{\mywidth}{(\linewidth-6*\tabcolsep)/3}%
\caption{\label{tab:screening2}Data Periods Removed during Data Quality Assessment}
tabular=p{\mywidth pt}|>{\centering}p{\mywidth pt}|>{\centering\arraybackslash}p{\mywidth pt},

showframe is only used to show that it works.