1

I'm writting a two column document, which is essentially the extended abstract of another document I have. I've been trying to include some of the tables I have in the extended abstract, but simply adding the tables does not work very well as their size ruins the document layout. I've been trying to resize the tables, but every solution I've come across for a tabular or tabularx, such as resizebox or scalebox doesn't seem to want to work for the csvreader.

How do I apply one of these solutions to my existing table code? I want to scale the table so it fits inside the linewidth

Here's how my code looks for the tables (I included all the packages to make sure no weird interactions are at fault):

\documentclass[10pt,a4paper,twocolumn]{article}
\usepackage{graphicx} % Enhanced LaTeX Graphics

\usepackage{subfigure} % subcaptions for subfigures
\usepackage{subfigmat}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{csvsimple}
\usepackage{siunitx}
\usepackage{float}

\setlength{\topmargin}{-10.4mm}
\setlength{\headheight}{0.0mm}
\setlength{\headsep}{10.0mm}
\setlength{\textwidth}{160mm}
\setlength{\textheight}{242mm}
\setlength{\oddsidemargin}{0mm}
\setlength{\evensidemargin}{0mm}
\setlength{\marginparwidth}{0mm}
\setlength{\marginparsep}{0mm}

\begin{document}

\begin{table}
\centering
\csvreader[no head,
    before reading=\sisetup{round-mode=places,round-precision=2,round-integer-to-decimal}\caption{Baseline GF Competition Circle Track 2014}\label{tab:baseline1},
    tabular={c | S l | S c | c | c},
    table head =Level & {Tokens} & (Max) & {Time} & (Max) & {Sucess(\%)} & Score\\\hline,
    late after line= \\,
    late after last line=\\\hline\multicolumn{7}{c}{Total Score: 1481}]{tables/BC14.csv}{}
{\csvcoli & \csvcolii & \csvcoliii & \csvcoliv & \csvcolv & \csvcolvi &   \csvcolvii}
\end{table}
\end{document}

simply changing the fontsize doesn't yield good results either. The table only gets an acceptable size with tiny but then the text is too small to be properly read.

edit: the code with the resize box gives me a Missing \endgroup inserted. I'm using pdfLatex

\begin{table}
\centering
\resizebox{\columnwidth}{!}{
\csvreader[no head,
    before reading=\sisetup{round-mode=places,round-precision=2,round-integer-to-decimal}\caption{Baseline GF Competition Circle Track 2014}\label{tab:baseline1},
    tabular={c | S l | S c | c | c},
    table head =Level & {Tokens} & (Max) & {Time} & (Max) & {Sucess(\%)} & Score\\\hline,
    late after line= \\,
    late after last line=\\\hline\multicolumn{7}{c}{Total Score: 1481}]{tables/BC14.csv}{}
{\csvcoli & \csvcolii & \csvcoliii & \csvcoliv & \csvcolv & \csvcolvi &  \csvcolvii}
}
\end{table}

edit2: an example of the .csv:

01,1.35,(2),12.2,(20),65,140
  • On my machine csvreader and resizebox are combined without any problem. Can you provide an extra MWE for this situation? Can you share (part of) your csv file? Also: you might consider table* instead of table to span the table over the two columns. FWIW: I've succesfully tried \begin{table} \centering \resizebox{\columnwidth}{!}{ \csvreader ... } \end{table} – Marijn Oct 14 '15 at 12:11
  • @Marijn when I add the resizebox like that I get a Missing \endgroup inserted. error – MasterOfTwo Oct 14 '15 at 12:17
  • 1
    @MasterOfTwo: Please add a sample csv file so that others can try to help. – user11232 Oct 14 '15 at 12:22
  • @HarishKumar done, but it's really nothing too complicated, any 7 columns will work and the table works fine without the resize... – MasterOfTwo Oct 14 '15 at 12:29
  • @MasterOfTwo I took the csv from your previous question. Please see the answer below. – user11232 Oct 14 '15 at 13:02
5

Here are two solutions. First we reduce the \tabcolsep and set a smaller font size.

before reading=\footnotesize\sisetup{round-mode=places,round-precision=2,round-integer-to-decimal}
        \caption{Baseline GF Competition Circle Track 2014}\label{tab:baseline1}
          \setlength{\tabcolsep}{2.5pt},

Adjust both as you wish.

In second, we use adjustbox package and resize the tabular to \columnwidth

before reading=\footnotesize\sisetup{round-mode=places,round-precision=2,round-integer-to-decimal}
        \caption{Baseline GF Competition Circle Track 2014}\label{tab:baselline1}
        \begin{adjustbox}{max width=\columnwidth},
after reading=\end{adjustbox},

Full code with both methods:

\documentclass[10pt,a4paper,twocolumn]{article}
\usepackage{graphicx} % Enhanced LaTeX Graphics

%\usepackage{subfigure} % subcaptions for subfigures   This is obsolete, use subcaption or subfig instead
\usepackage{subfigmat}   %% ????
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{csvsimple}
\usepackage{siunitx}
\usepackage{float}
\usepackage{showframe,lipsum}   %% just for demo
\usepackage{adjustbox}

\setlength{\topmargin}{-10.4mm}
\setlength{\headheight}{0.0mm}
\setlength{\headsep}{10.0mm}
\setlength{\textwidth}{160mm}
\setlength{\textheight}{242mm}
\setlength{\oddsidemargin}{0mm}
\setlength{\evensidemargin}{0mm}
\setlength{\marginparwidth}{0mm}
\setlength{\marginparsep}{0mm}

\begin{document}
\lipsum[1]
\begin{table}[htb]
\centering
\csvreader[no head,
    before reading=\footnotesize\sisetup{round-mode=places,round-precision=2,round-integer-to-decimal}
        \caption{Baseline GF Competition Circle Track 2014}\label{tab:baseline1}
          \setlength{\tabcolsep}{2.5pt},
    tabular={c | S l | S c | c | c},
    table head =Level & {Tokens} & (Max) & {Time} & (Max) & {Sucess(\%)} & Score\\\hline,
    late after line= \\,
    late after last line=\\\hline\multicolumn{7}{c}{Total Score: 1481}]{BC14.csv}{}
{\csvcoli & \csvcolii & \csvcoliii & \csvcoliv & \csvcolv & \csvcolvi &   \csvcolvii}
\end{table}
\begin{table}[htb]
\csvreader[no head,
    before reading=\footnotesize\sisetup{round-mode=places,round-precision=2,round-integer-to-decimal}
        \caption{Baseline GF Competition Circle Track 2014}\label{tab:baselline1}
        \begin{adjustbox}{max width=\columnwidth},
    after reading=\end{adjustbox},
    tabular={c | S l | S c | c | c},
    table head =Level & {Tokens} & (Max) & {Time} & (Max) & {Sucess(\%)} & Score\\\hline,
    late after line= \\,
    late after last line=\\\hline\multicolumn{7}{c}{Total Score: 1481}]{BC14.csv}{}
{\csvcoli & \csvcolii & \csvcoliii & \csvcoliv & \csvcolv & \csvcolvi &   \csvcolvii}
\end{table}
\lipsum[2]
\end{document}

enter image description here

  • yup, that solved it, thanks. I think I tried adjustbox before, but was placing the \end{..} in after table. I guess I can see why that wouldn't work... – MasterOfTwo Oct 14 '15 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.