我正在嘗試從 CSV 檔案中排版一長行,其中包含特殊字元但不包含空格。因為我希望它在視覺上與周圍的文字不同,所以我使用verbatim
環境。有問題的行看起來像這樣:
"%TIME_STAMP%","%TIME_SERIES_NAME_(metric)%","%ENTITY%","%FIRST_TAG_VALUE%","%SECOND_TAG_VALUE%","%THIRD_TAG_VALUE%","VALUE"
我已經嘗試過verbatim
和spverbatim
環境(來自包spverbatim
),它可以很好地處理特殊符號,但沒有換行(即使我只是為了實驗而人為添加空格)。我嘗試使用,listings
但特殊字元的存在使我的檔案無法編譯(即使我使用反斜線轉義下劃線和百分號)
所以我的問題是 - 如何在逐字或spverbatim等環境中使乳膠在空格和一些特殊字符(如逗號)上換行?如果不可能,使用清單會有幫助嗎?如果是,如何轉義特殊字元?
這是無法透過清單進行編譯的內容
\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}
答案1
我添加了literate
密鑰和一些(更多)特殊字元。
\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}