이스케이프된 텍스트 내부의 목록 목록에서 줄 바꿈

이스케이프된 텍스트 내부의 목록 목록에서 줄 바꿈

Lstlisting 환경 내에서 줄바꿈 표시를 수정하려고 합니다. 특히 이스케이프된 영역 내부에 있는 목록의 일부에서 문제를 해결하려고 합니다.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage{listings}
\lstset{}


\definecolor{keywordColor}{HTML}{0033B3}
\definecolor{parameterColor}{HTML}{067D17}
\definecolor{commentColor}{HTML}{8C8C8C}
\definecolor{scenarioColor}{HTML}{871094}

\newcommand{\lstKeyword}[1]{{\textcolor{keywordColor}{#1}}}
\newcommand{\lstParameter}[1]{{\textcolor{parameterColor}{#1}}}
\newcommand{\lstScenario}[1]{{\textcolor{scenarioColor}{\textit{#1}}}}

\lstdefinestyle{bddStory}
{
  frame=single,
  captionpos=b,
  commentstyle=\color{commentColor},
  keywordstyle=\color{keywordColor},
  morekeywords={Given ,When ,Then ,And ,Narrative,Examples},
  escapeinside={<@}{@>},
  showspaces=false,
  showtabs=false,
  showstringspaces=false,
  breaklines=true,
  postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
  breakatwhitespace=true
}

\title{Example Issue}

\begin{document}
\begin{lstlisting}[style=bddStory]
<@\lstScenario{Scenario: A scenario title is too long and can't fit into a single line which causes issues in the highlighting}@>
Given there is some further content
\end{lstlisting}

\end{document}

콘텐츠는 다음과 같이 렌더링됩니다. 상자에 있는 두 개의 구분선과 새 줄에 누락된 화살표가 문제입니다.

새 줄의 잘못된 렌더링

답변1

listings이 분할된 상자는 패키지 의 알려진 버그입니다 . tcolorbox님의 listings패치를 사용하여 문제를 해결할 수 있습니다. 인수가 패키지에 전달되는 방식이 listings다릅니다.

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage{tcolorbox}

\tcbuselibrary{skins, breakable, listings}

\definecolor{keywordColor}{HTML}{0033B3}
\definecolor{parameterColor}{HTML}{067D17}
\definecolor{commentColor}{HTML}{8C8C8C}
\definecolor{scenarioColor}{HTML}{871094}

\newcommand{\lstKeyword}[1]{{\textcolor{keywordColor}{#1}}}
\newcommand{\lstParameter}[1]{{\textcolor{parameterColor}{#1}}}
\newcommand{\lstScenario}[1]{{\textcolor{scenarioColor}{\textit{#1}}}}

\lstdefinestyle{bddStory}
{
  captionpos=b,
  commentstyle=\color{commentColor},
  keywordstyle=\color{keywordColor},
  morekeywords={Given ,When ,Then ,And ,Narrative,Examples},
  escapeinside={<@}{@>},
  showspaces=false,
  showtabs=false,
  showstringspaces=false,
  breaklines=true,
  postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
  breakatwhitespace=true
}

\title{Example Issue}

\newtcblisting{mylisting}[1]{
  enhanced,
  breakable,
  listing only,
  boxrule=0.8pt,
  sharp corners,
  top=0mm,
  bottom=0mm,
  left=2mm,
  right=2mm,
  boxsep=0mm,
  colframe=black,
  colback=white,
  listing options={
    style=#1
  }
}


\begin{document}
\begin{mylisting}{bddStory}
<@\lstScenario{Scenario: A scenario title is too long and can't fit into a single line which causes issues in the highlighting}@>
Given there is some further content
\end{mylisting}


\end{document}

누락된 화살표에 대해서는 패키지가 이스케이프된 영역에 내용을 listings추가하려고 시도하지 않는 것 같습니다 . postbreak아래 예를 참조하세요.

여기에 이미지 설명을 입력하세요

만약 너라면정말이 기능을 구현하고 싶은데 다음 두 게시물을 찾았습니다.

관련 정보