我正在尝试调整由包tabular
生成的列宽度\DTLdisplaydb
datatool
喜欢这里的tabular
环境。但我没想出什么解决办法。
我尝试了一些非常糟糕的事情:
\documentclass[10pt,a4paper,landscape]{report}
\usepackage{datatool}
\usepackage[small,compact]{titlesec}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} % utf8x causes problem with accents in header columns
\usepackage[frenchb]{babel}
\usepackage[margin=1in]{geometry}
\DTLloaddb{mydb}{db.csv}
\let\oldtabular\tabular
\let\endoldtabular\endtabular
\newcolumntype{M}{>{\begin{varwidth}{8cm}}l<{\end{varwidth}}} %M is for Maximal column
\renewenvironment{tabular}{\tabular[|M|]}{\endtabular}
\begin{document}
\begin{table}\footnotesize
%\begin{minipage}{0.9\textwidth} %Useless here
\DTLdisplaydb{mydb}
%\end{minipage}
\end{table}
\end{document}
我收到以下错误:
! TeX capacity exceeded, sorry [input stack size=5000].
\tabular ->\tabular
[|M|]
l.67 \DTLdisplaydb{mydb}
以下是示例数据库:
entete,entete,entete,
1,"big string paragraph with a lot of charachter like that. I don't know what to say.. blablablablablablablablablabla... ", "reblabla"
2,"text","text"
当然,还有其他方法。
答案1
这是一个可能的解决方案:
\documentclass[10pt,a4paper,landscape]{report}
\usepackage{datatool}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage[margin=1in]{geometry}
\usepackage{varwidth}
\usepackage{array}
\begin{filecontents*}{db.csv}
entete,entete,entete
1,"big string paragraph with a lot of charachter like that. I don't know what to say.. blablablablablablablablablabla... ", "reblabla"
2,"text","text"
\end{filecontents*}
\DTLloaddb[keys={col1,col2,col3}]{mydb}{db.csv}
\renewcommand{\dtlstringformat}[1]{\begin{varwidth}[t]{8cm}#1\end{varwidth}}
\begin{document}
\DTLdisplaydb{mydb}
\end{document}
结果是:
(第一列右对齐,因为它只包含整数。)