我想使用 listings 包来实现这一点(通过 \lstinputlisting 轻松导入)。有什么想法吗?或者还有其他方法可以解决我的问题吗?如果不突出显示,很难理解给定的信息。
\documentclass{scrreprt}
\usepackage{listings}
\begin{document}
\lstinputlisting{example.tsv}
\end{document}
编辑:示例数据
0.004 1100.000 0.000 1200.000 180.000 0.000 180.000
0.008 1099.998 0.629 1200.000 180.000 0.000 180.000
0.012 1099.992 1.258 1200.000 180.000 0.000 180.000
0.016 1099.982 1.887 1200.000 180.000 0.000 180.000
0.020 1099.968 2.516 1200.000 180.000 0.000 180.000
0.024 1099.951 3.144 1200.000 180.000 0.000 180.000
0.028 1099.929 3.773 1200.000 180.000 0.000 180.000
编辑2:
好的,我现在正在使用 pgfplotstable。
\documentclass{scrreprt}
\usepackage{colortbl}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}[h!]
\begin{center}
\pgfplotstabletypeset[
skip first n=2, % skip lines in beginning
skip rows between index={5}{10}, % skip rows from {<begin>}{<end>}
skip rows between index={10}{20},
col sep=tab, % the seperator in our .csv file
columns/0/.style={
column name=$Time [\si{\milli\second}]$, % name of first column
column type/.add={>{\color{black}}}{},string type
},
columns/1/.style={
column name=$X [\si{\milli\meter}]$,
column type/.add={>{\color{blue!80!black}}}{},string type
},
columns/2/.style={
column name=$Y[\si{\milli\meter}]$,
column type/.add={>{\color{red!50!black}}}{},string type
},
columns/3/.style={
column name=$Z[\si{\milli\meter}]$,
column type/.add={>{\color{green!50!black}}}{},string type
},
columns/4/.style={
column name=$X_u [^\circ]$,
column type/.add={>{\color{blue!80!black}}}{},string type
},
columns/5/.style={
column name=$Y_u [^\circ]$,
column type/.add={>{\color{red!50!black}}}{},string type
},
columns/6/.style={
column name=$Z_u [^\circ]$,
column type/.add={>{\color{green!50!black}}}{},string type
},
every head row/.style={
before row={\toprule}, % have a rule at top
after row={\midrule}
}, % rule under units
every last row/.style={
after row={\bottomrule}
}, % rule at bottom
postproc cell content/.append code={ % add dots between rows
\ifnum\pgfplotstablerow=4
\pgfkeyssetvalue{/pgfplots/table/@cell content}{\ensuremath{\vdots}}
\fi}
]{Code/trajectory.txt} % filename/path to file
\caption{Data}
\label{table1}
\end{center}
\end{table}
\end{document}
它看起来是这样的:
编辑3:为我添加了最终结果。希望它能为别人节省一些时间!