根据标题,我试图将长表格(多页长)强制转换为文本宽度(例如,不要通过剪切文本、将其分成几行来超出边距,我不在乎。):我试过 a、b。它们不起作用有什么想法吗?
A:
\usepackage{pgfplotstable}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{pgfplots}
\usepackage[margin=4cm]{geometry}
\begin{document}
\pgfplotstableset{
begin table=\begin{longtable},
end table=\end{longtable},
}
\setlength\LTcapwidth{\textwidth} % default: 4in (rather less than \textwidth...)
\setlength\LTleft{0pt} % default: \parindent
\setlength\LTright{0pt} % default: \fill
% Preamble: \pgfplotsset{compat=1.15}
\pgfplotstabletypeset[
columns={a,b,c,d},
columns/a/.style={string type}
]{
a b c d
Loremdoloremadfasdfasfassdfasfassadfsadfasdfasdfasdfasdfasfasdipsum 3 15673 0.136264
werewwer 3 16732 0.143577
wewerwerwerwer 8 99998.5 1.28447
}
\end{document}
乙:
\documentclass[a4paper,12pt]{article}
\usepackage{pgfplotstable}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{pgfplots}
\usepackage[margin=4cm]{geometry}
\begin{document}
\pgfplotstableset{
begin table=\begin{longtabu} to \textwidth,
end table=\end{longtabu},
}
% Preamble: \pgfplotsset{compat=1.15}
\pgfplotstabletypeset[
columns={a,b,c,d},
columns/a/.style={string type}
]{
a b c d
Loremdoloremadfasdfasfassdfasfassadfsadfasdfasdfasdfasdfasfasdipsum 3 15673 0.136264
werewwer 3 16732 0.143577
wewerwerwerwer 8 99998.5 1.28447
}
\end{document}
答案1
好的,这似乎可以使用 longtabu、collcell 和 seqsplit 来实现:我创建了一种可拉伸的新类型的 Y 列(例如基于 X 类型),并使用 seqsplit 来获得换行文本效果,因为我的文本不是由可连字符的英文单词组成的。
\documentclass[a4paper,12pt]{article}
\usepackage{pgfplotstable}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{pgfplots}
\usepackage[margin=4cm]{geometry}
\usepackage{seqsplit}
\usepackage{collcell}
\begin{document}
\newcolumntype{Y}{>{\collectcell\seqsplit}X<{\endcollectcell}}
\pgfplotstableset{
begin table=\begin{longtabu} to \textwidth {@{}Yccc@{}},
end table=\end{longtabu},
}
% Preamble: \pgfplotsset{compat=1.15}
\pgfplotstabletypeset[
columns={g,b,c,d},
columns/g/.style={string type},
]{g b c d
Loremdoloremadfasdfasfassdfasfassadfsadfasdfasdfasdfasdfasfasdipsum 3 15673 0.136264
werewwer 3 16732 0.143577
wewerwerwerwer 8 99998.5 1.28447
}
\end{document}