首页 > 解决方案 > 来自 CSV 文件的乳胶表

问题描述

以下用于从 csv 文件创建 Latex 表的代码在表顶部缺少水平线。

\documentclass{article}
\usepackage{csvsimple} 

% Make csv in question
\begin{filecontents*}{check.csv}
labels,names,A,C,V,tools
a,example,838,663,683,
b,otter,353,215,192,
d,\textbf{broccoli},79,79,117,
e,fibredensityandcrosssection,1086,849,868,
ad,hcp-prefree:exec-centos7.freebuild-centos4-latest,70,76,157,
ar,shots47s\_fmriprep-1.2.3,,,,453
\end{filecontents*}

\begin{table*}[!ht]
\csvreader[%
 tabular={|c|c|c|c|c|c|},
        table head = \textbf{Labels} &\textbf{{names}} & \textbf{A} & \textbf{C} & \textbf{V} & \textbf{T}\\\hline,
        late after line= \\,
        late after last line=\\\hline %
        ]{check.csv}{labels=\labels,names=\names,A=\A,C=\C,V=\V,tools=\tools}%
        {\labels & \names & \A & \C & \V & \tools}
       \centering
        \caption{\label{table1}Number by category}
\end{table*}
 
\end{document}

我们如何在表格顶部添加顶部水平线?

标签: csvlatex

解决方案


请注意,构建这样的数据监狱是不好的风格。看看http://betterposters.blogspot.de/2012/08/the-data-prison.htmlhttps://www.inf.ethz.ch/personal/markusp/teaching/guides/guide-tables。 pdfhttps://wiert.me/2014/04/03/andre-vatter-google-wie-tabellen-eigentlich-aussehen-sollten-%EF%BB%BF/获取一些关于漂亮桌子的指南。

 \documentclass{article}
 \usepackage{csvsimple} 

 % Make csv in question
\begin{filecontents*}{check.csv}
labels,names,A,C,V,tools
a,example,838,663,683,
b,otter,353,215,192,
d,\textbf{broccoli},79,79,117,
e,fibredensityandcrosssection,1086,849,868,
ad,hcp-prefree:exec-centos7.freebuild-centos4-latest,70,76,157,
ar,shots47s\_fmriprep-1.2.3,,,,453
\end{filecontents*}
\begin{document}
\begin{table*}[!ht]
\csvreader[%
 tabular={|c|c|c|c|c|c|},
        table head = \hline\textbf{Labels} &\textbf{{names}} & \textbf{A} & \textbf{C} & \textbf{V} & \textbf{T}\\\hline,
        late after line= \\,
        late after last line=\\\hline %
        ]{check.csv}{labels=\labels,names=\names,A=\A,C=\C,V=\V,tools=\tools}%
        {\labels & \names & \A & \C & \V & \tools}
       \centering
        \caption{\label{table1}Number by category}
\end{table*}
 
 \end{document}

在此处输入图像描述


推荐阅读