1

I am trying to generate something similar to this Rainbow Style. Rainbow TSV Example

I would like to use the listings package for that (easy import through \lstinputlisting). Any Ideas? Or are there other solutions for my problem? Without any highlighting it is just so difficult to comprehend the given information.

\documentclass{scrreprt}
\usepackage{listings}
\begin{document}
\lstinputlisting{example.tsv}
\end{document}

enter image description here

edit: Example data

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

edit2:

Ok I am using pgfplotstable now.

\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}

And that is how it looks:

Example Table

edit3: added final result for me. hope it spares some time for someone else!

  • 3
    Welcome to TeX.SX! Use pgfplotstable. And please include your example data into the post, so others have something to play with. – TeXnician Nov 20 '18 at 16:17
  • Thanks for the tip! See my result in original post. – BananaBowser Nov 21 '18 at 13:14
  • 2
    I am glad that I could help, but maybe you want to post your edit as an answer rather than keeping it in the question. That way this post could be marked as solved. – TeXnician Nov 22 '18 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.