2

as per the header I'm trying to force a long table (multipages long) into textwidth (e.g. not go over the margins by either cutting the text, breaking it into lines, I don't care.): I've tried a, b. They don't work Any ideas?

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}

B:

\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}
  • In what sense do they not work??? The asdf part is simply too long to fit in \textwidth. What behavior do you expect? – Symbol 1 Jul 30 '18 at 07:06
  • See also https://tex.stackexchange.com/questions/54302/how-to-fit-landscape-multi-page-table-to-textwidth – Symbol 1 Jul 30 '18 at 07:07
  • @Symbol1 the table should not go over the margins. either break the text or not show it. The link you send over is option A in my examples. – Koenig Lear Jul 30 '18 at 10:32

1 Answers1

2

Ok this seems to work using longtabu, collcell and seqsplit: I've created a new type of column Y that is stretachable (e.g. based on X type) and used seqsplit to get the wrap-text effect given that my text is not made of hyphen-able English words.

\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}