csvsimple – Handling Underscores Incorrectly with csvsimple

csvcsvsimpleinput-encodings

I try to print a .csv file using csvsimple. The column headers of that CSV file contain underscores.

Within the csvsimple documentation, I found the option respect underscore=true option that is supposed to make LaTeX handle the underscores correctly.

So far, my code can be compiled, but the underscores are rendered in the pdf as an unknown character:

Illustration of wrong underscore handling.

Here is a minimal working example:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{csvsimple}
\usepackage{array,booktabs}

\begin{document}

    \csvautobooktabular[respect underscore=true]{data.csv}

\end{document}

And here the respective CSV file:

test_col,col_test
1824,4
1892,3
1948,3
1968,3

Best Answer

Add

\usepackage[T1]{fontenc}

The default OT1 encoding doesn't have ascii symbols in the places you might expect.