我有mycsv.csv
:
Nr,A,B,C
1,a,b,g
2,c,d,h
3,e,f,i
使用此 Phyton 代码:
import pandas as pd
testo = pd.read_csv("mycsv.csv")
columns = [
('','Something'),
('Multicolumn','A'),
('Multicolumn','B'),
('Something else',''),
]
testo.columns = pd.MultiIndex.from_tuples(columns)
testo.head()
testo.style.hide(axis="index").to_latex("myout.tex",hrules=True,
multicol_align='c')
我得到了myout.tex
:
\begin{tabular}{rlll}
\toprule
& \multicolumn{2}{c}{Multicolumn} & Something else \\
Something & A & B & \\
\midrule
1 & a & b & g \\
2 & c & d & h \\
3 & e & f & i \\
\bottomrule
\end{tabular}
我想\cmidrule{2-3}
在标题中添加:
\documentclass[10pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{rlll}
\toprule
& \multicolumn{2}{c}{Multicolumn} & Something else \\
\cmidrule{2-3}
Something & A & B & \\
\midrule
1 & a & b & g \\
2 & c & d & h \\
3 & e & f & i \\
\bottomrule
\end{tabular}
\end{document}
我该怎么做?
作为一种快速而肮脏的黑客攻击,可以使用https://stackoverflow.com/a/32276740/2777074将以下内容偷偷
\cmidrule{2-3}
放入代码中: