对于我的论文,我需要一个较大的数据框作为LaTeX表。
它包含126行和5列。
我知道,有一个功能df.to_latex(buf='citations.tex',largetable=True)
。但是,当我运行该函数时,它会在列中剪切我的字符串!
我正在使用jupyter笔记本。因此,当我在此处打印数据框时,列中的字符串会被缩写。没关系但是,当我在数据框上使用to_latex()
函数时,这些列也将被缩写。为什么会这样?
我的数据框:
title authors journal year doi
A visualization and modeling tool for security... Reijo M. Savola; Petri Heinonen 2011 Information Security for South Africa 2011 10.1109/ISSA.2011.6027518
Information security requirements – Interpreti... Mariana Gerber; Rossouw von Solms Computers & Security 2008 https://doi.org/10.1016/j.cose.2008.07.009
使用df.head(2).to_latex()
之后
LaTeX输出:
'\\begin{tabular}{llllrl}\n\\toprule\n{} & title & authors & journal & year & doi \\\\\n\\midrule\n0 & A visualization and modeling tool for security... & Reijo M. Savola; Petri Heinonen & 2011 Information Security for South Africa & 2011 & 10.1109/ISSA.2011.6027518 \\\\\n1 & Information security requirements – Interpreti... & Mariana Gerber; Rossouw von Solms & Computers \\& Security & 2008 & https://doi.org/10.1016/j.cose.2008.07.009 \\\\\n\\bottomrule\n\\end{tabular}\n'
如您所见,textoutput不是数据框的输出,而是印刷版本的输出。即使导出到文件也无济于事。 df.to_latex('citations.tex',longtable=True)
是所使用的命令,但无法正常工作。
为什么会发生这种情况,以及如何解决?