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{adjustbox}
\usepackage{datatool}
\usepackage[backend=bibtex8]{biblatex}
\newcommand\myhead[1]{\mbox{\centering\cellcolor{blue}\color{white}\bfseries #1}} %Table header style
%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}
\csvreader[head to column names, column count=3,respect all, tabular=l|c|c,
table head=\myhead{Timestamp} & \myhead{Fields} & \myhead{Issue} \\\hline,
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}
\csvreader[head to column names, column count=3,respect all, tabular=l|c|c,
table head=\myhead{Timestamp} & \myhead{Fields} & \myhead{Issue} \\\hline,
late after first line=\\,
late after line=\\\hline,
]%
{file2.csv}{}{%
\csvcoli & \csvcolii & \csvcoliii
}
\end{table}
\end{document}
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.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.tabularx
. However, according to what I find it does not get directly supported incvsimple
. Of course, one could try to hack it.