我正在写一份两栏文档,它实际上是我另一份文档的扩展摘要。我一直试图将一些表格包含在扩展摘要中,但简单地添加表格效果不佳,因为它们的大小会破坏文档布局。我一直在尝试调整表格的大小,但我遇到的所有针对 或 的解决方案tabular
,tabularx
例如resizebox
或scalebox
似乎都无法用于csvreader
。
如何将这些解决方案之一应用于我现有的表格代码?我想缩放表格,使其适合linewidth
这是我的代码如何查找表格(我包含了所有的包以确保没有奇怪的交互导致的错误):
\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}
简单地改变字体大小也不会产生好的效果。表格只能获得可接受的大小,tiny
但文本太小而无法正确阅读。
编辑:带有调整大小框的代码给了我一个Missing \endgroup inserted.
我正在使用的 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:.csv 的示例:
01,1.35,(2),12.2,(20),65,140
答案1
这里有两个解决方案。首先我们缩小\tabcolsep
并设置较小的字体大小。
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},
根据需要调整两者。
其次,我们使用adjustbox
包并调整表格大小以\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},
两种方法的完整代码:
\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}