tabularx 与条件的冲突

tabularx 与条件的冲突

来自 csv 文件的页面表。我的问题:表格前的条件出现错误。您知道我该如何修复此问题吗?(并非所有数据都显示出来,但重要的是表格保持多页状。

\documentclass[a4paper, 11pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage[left=3cm,top=3cm,right=3cm]{geometry}
\usepackage{tabularx}
\usepackage{ltablex}
  \keepXColumns
\usepackage{xfrac}
\usepackage{float}
\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}
\usepackage{csvsimple}
%________________________________________________________________________
\newenvironment{conditions}
{\par\vspace{\abovedisplayskip}\noindent\tabularx{\textwidth}{>{$}l<{$} @{${}={}$} X}}
{\endtabularx\par\vspace{\belowdisplayskip}}
%________________________________________________________________________
% Part 4
\begin{filecontents*}{exp4.csv}
0.2,320.1
0.4,319.5
0.6,317.7
\end{filecontents*}
%________________________________________________________________________
\begin{document}
%________________________________________________________________________

\begin{conditions} 
\kappa & specific conductivity [$\si{\siemens~\cm^{-1}}$]  \\
 \end{conditions}

\begin{tabularx}{\textwidth}{|X|X|}
    \hline
    \bfseries V EDTA [\si{\milli\liter}] & \bfseries value 1 
    \csvreader[no head]{exp4.csv}{}{\\ \hline \csvcoli & \csvcolii }
    \\ \hline
\end{tabularx}

\end{document}

答案1

以下是使用 eitherxltabular或 的两个示例longtable

在此处输入图片描述

\documentclass[a4paper, 11pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage[left=3cm,top=3cm,right=3cm]{geometry}
\usepackage{tabularx}
%\usepackage{ltablex} % removed to get rid of error message
%  \keepXColumns
\usepackage{xltabular} % added to be able to use xltabular environment. with this package, use tabularx if you don't want a pagebreak, use xltabular of you do want a pagebreak inside of a table.
\usepackage{xfrac}
\usepackage{float}
\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}
\usepackage{csvsimple}
%________________________________________________________________________
\newenvironment{conditions}
{\par\vspace{\abovedisplayskip}\noindent\tabularx{\textwidth}{>{$}l<{$} @{${}={}$} X}}
{\endtabularx\par\vspace{\belowdisplayskip}}
%________________________________________________________________________
% Part 4
\begin{filecontents*}{exp4.csv}
0.2,320.1
0.4,319.5
0.6,317.7
\end{filecontents*}
%________________________________________________________________________
\begin{document}
%________________________________________________________________________

\begin{conditions} 
\kappa & specific conductivity [$\si{\siemens~\cm^{-1}}$]  \\
\end{conditions}

xltabular version

\begin{xltabular}{\textwidth}{|X|X|}
    \hline
    \bfseries V EDTA [\si{\milli\liter}] & \bfseries value 1 
    \csvreader[no head]{exp4.csv}{}{\\ \hline \csvcoli & \csvcolii }
    \\ \hline
\end{xltabular}

longtable version

\begin{longtable}{|l|l|}
    \hline
    \bfseries V EDTA [\si{\milli\liter}] & \bfseries value 1 
    \csvreader[no head]{exp4.csv}{}{\\ \hline \csvcoli & \csvcolii }
    \\ \hline
\end{longtable}

\end{document}

相关内容