1

I am trying to typeset a long line from CSV file, that contains special characters but no whitespaces. Since I would like it to be visually different from surrounding text, I am using verbatim environment. The problematic line looks somthing like this:

"%TIME_STAMP%","%TIME_SERIES_NAME_(metric)%","%ENTITY%","%FIRST_TAG_VALUE%","%SECOND_TAG_VALUE%","%THIRD_TAG_VALUE%","VALUE"

I already tried verbatim and spverbatim environment (from package spverbatim), which worked well with special symbols, but didn't wrap lines (even when I artificially added whitespace just for sake of experimenting). I attempted to use listings but presence of special characters made my file impossible to compile (even when I escaped underscores and percent symbols using backslash)

So my question is - how to make latex wrap lines on both whitespace and some special character - like comma - inside environments like verbatim or spverbatim? If it is not possible, would using listings help? If yes, how to escape special characters?

Here is what fails to compile with listings

\documentclass[12pt, oneside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,left=3.5cm,right=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{url}
\usepackage[hidelinks,breaklinks]{hyperref}
\usepackage[slovak]{babel} 

\usepackage{amsthm} 

\usepackage{spverbatim}
\usepackage{listings} %dlhe csv riadky
\lstset{
   breaklines=true,
   basicstyle=\ttfamily}

%\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}

\linespread{1.25} 


\begin{document}     

\begin{lstlisting}
"%ČASOVÁ_PEČIATKA%","%NÁZOV_ČASOVÉHO_RADU%", "%ENTITA%","%HODNOTA_TAGU%","%ÚDAJ%"
\end{lstlisting}

\end{document}
3
  • Welcome to TeX.SX! Usually listings does not care about special characters. Could you show us, what you have tried (compilable document)?
    – TeXnician
    Apr 16, 2017 at 15:34
  • @TeXnician I added the exact string, not just example, because surprisingly, the example one can be compiled. Meybe the special characters like č are causing troubles?
    – filox
    Apr 16, 2017 at 15:47
  • It's not a problem of TeX characters, but of literal encoding.
    – TeXnician
    Apr 16, 2017 at 15:47

1 Answer 1

1

I've added the literate key and some (more) special characters.

broken line

\documentclass[12pt, oneside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,left=3.5cm,right=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{url}
\usepackage[hidelinks,breaklinks]{hyperref}
\usepackage[slovak]{babel} 

\usepackage{amsthm} 

\usepackage{spverbatim}
\usepackage{listings} %dlhe csv riadky
\lstset{
   breaklines=true,
   basicstyle=\ttfamily,
   literate=    {á}{{\'a}}1
{č}{{\v{c}}}1
{ď}{{\v{d}}}1
{é}{{\'e}}1
{ě}{{\v{e}}}1
{í}{{\'i}}1
{ň}{{\v{n}}}1
{ó}{{\'o}}1
{ř}{{\v{r}}}1
{š}{{\v{s}}}1
{ť}{{\v{t}}}1
{ú}{{\'u}}1
{ů}{{\r{u}}}1
{ý}{{\'y}}1
{ž}{{\v{z}}}1
{Á}{{\'A}}1
{Č}{{\v{C}}}1
{Ď}{{\v{D}}}1
{É}{{\'E}}1
{Ě}{{\v{E}}}1
{Í}{{\'I}}1
{Ň}{{\v{N}}}1
{Ó}{{\'O}}1
{Ř}{{\v{R}}}1
{Š}{{\v{S}}}1
{Ť}{{\v{T}}}1
{Ú}{{\'U}}1
{Ů}{{\r{U}}}1
{Ý}{{\'Y}}1
{Ž}{{\v{Z}}}1}

%\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}

\linespread{1.25} 


\begin{document}     

\begin{lstlisting}
"%ČASOVÁ_PEČIATKA%","%NÁZOV_ČASOVÉHO_RADU%", "%ENTITA%","%HODNOTA_TAGU%","%ÚDAJ%"
\end{lstlisting}

\end{document}
5
  • unfortunately, your code doesn't compile ! Package inputenc Error: Unicode char �\lst@FillFixed@ (U+5AA) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.38 "%ČASOVÁ _PEČIATKA%","%NÁZOV_ČASOVÉHO_RADU%", "%ENTITA%","%HODNOTA...
    – filox
    Apr 16, 2017 at 15:53
  • @filox Does it compile now?
    – TeXnician
    Apr 16, 2017 at 15:54
  • unfortunately no, still the same exact seme error
    – filox
    Apr 16, 2017 at 15:56
  • ok, I fixed it by adding characters from this answer stackoverflow.com/a/16084246/7378363
    – filox
    Apr 16, 2017 at 15:58
  • @filox Great, I updated it (I compiled with LuaLaTeX which supports full unicode input, my fault).
    – TeXnician
    Apr 16, 2017 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .