
다음과 같이 csvsimple을 사용하여 라텍스로 가져온 간단한 두 줄의 csv 파일이 있습니다.
\begin{filecontents*}{data.csv}
1,2,3,4,5
101,102,104,105,106
-1,-2,-3,-4,-5
\end{filecontents*}
...
\begin{table}
\begin{tabular}{*{5}{c}}
\csvreader{data.csv}{}{\\ \csvlinetotablerow}
\end{tabular}
\end{table}
하지만 테이블 왼쪽에 머리글을 추가하고 싶은데 할 수 있는 방법이 없었습니다.
즉, 나는 다음과 같은 것을 원합니다 :
어떻게 그렇게 할 수 있나요?
답변1
두 줄로 구성된 csv 파일의 경우 \csviffirstrow
. 두 헤더를 첫 번째 줄과 다음 줄의 설정에 넣기만 하면 됩니다.
\documentclass[12pt]{article}
\usepackage{csvsimple}
\begin{filecontents*}{data.csv}
1,2,3,4,5
101,102,104,105,106
-1,-2,-3,-4,-5
\end{filecontents*}
\begin{document}
\begin{table}
\csvloop{
file=data.csv,
tabular=|*{6}{c|},
table head=\hline,
command=\csviffirstrow{$I_c$}{$U_\mathrm{same}$} & \csvlinetotablerow,
late after line=\\\hline,
}
\end{table}
\end{document}