“lstlisting 环境中 URL 中的换行问题

“lstlisting 环境中 URL 中的换行问题

breaklines尽管和都设置为 true, lstlisting 环境中的换行符对于 URL 不起作用。URLbreakatwhitespace未被换行,并且文本超出了页面边界。

有人能帮我解决这个问题吗?我已经将breaklines和设置breakatwhitespace为 true,但 lstlisting 环境中的 URL 无法正确跨行,导致文本超出页边距。您可以在此屏幕截图中看到问题。

在此处输入图片描述

任何帮助或建议都将不胜感激。谢谢!

\documentclass{article}
\usepackage{geometry}
\usepackage{xcolor} 
\usepackage{listingsutf8}
\lstset{
    basicstyle=\ttfamily\color{black}\small,
    frame=tb,
    extendedchars=true,
    showspaces=false,
    showstringspaces=false,
    numbers=left,
    numberstyle=\tiny,
    breaklines=true,
    backgroundcolor=\color{yellow!20!white},
    breakautoindent=true,
    breakatwhitespace=true
}

\begin{document}

\section{Introduction}
Test this part of the file: breaking line shouldn't be a problem
in the normal text. But as soon as I have a Listing with a long
text (e.g. token or a hash) then it doesn't work properly. What
also doesn't work is when I'm having a \ texttt in the end of the
line like \texttt{ThisExampleForLongTextWhichDoesNotBreakeAtTheEndOfTheLine}

\begin{lstlisting}
GET https://192.168.178.73:8443/v1/devices/ HTTP/1.1
Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjEwOWMwNTA5MDYzYTk3YmFkMGE2ZWEzMmM3MmE3NmExMzg4NWFkOWRiMmM5OWY0ZmNiNDJiZGEwNQ3OTYwMDcifQ.eyJpc3MiOiJhN2ZkMDAyNi01NTc5LTQ4ZTItYjg3MS1hMjA5YWExNjhhYmUiLCJ0eXBlIjoiYWNjZXNzIiwiYXVkIjoiaG9tZXNtYXJ0LmxvY2FsIiwic3ViIjoiZTQwNTUwMjYtY2JkMC00MjgyLWE0NmEtZWRhOTI5OTE2Zjk1IiwiaWF0IjoxNjgyMDMDc1LCJleHAiOjE5OT2NTQwNzV9.dhX3QfPqVYklVYGWWskvvpi81tVl6k7dZEJFbGNfOncnq2ATnkzR1HZsdFSNbirsu59k2xv2LKdwq5kR_HxEA
Host: 192.168.178.73:8443
Connection: Keep-Alive
\end{lstlisting}

\end{document}

相关内容