내가 사용하는 코드가 있습니다
\begin{lstlisting}
line1
line2
line3
\end{lstlisting}
1호선과 3호선을 비스듬하게 표시하고 싶습니다. 이것이 어떻게 이루어질 수 있습니까?
답변1
구분 기호를 사용할 수 있습니다.
\documentclass{article}
\usepackage{listings}
\lstdefinestyle{mystyle}{
basicstyle = \ttfamily ,
moredelim = [is][\itshape]{|}{|}
}
\begin{document}
\begin{lstlisting}[style=mystyle]
|line1
line2|
line3
\end{lstlisting}
\end{document}
\begin{lstlisting}[style=mystyle]
|line1|
line2
|line3|
\end{lstlisting}
답변2
복잡성에 따라 이를 달성하기 위해 환경의 선택적 인수를 사용할 수 있습니다 verbatimbox
.
\documentclass{article}
\usepackage{verbatimbox,xcolor}
\begin{document}
\newcommand\formatting{%
\ifnum\theVerbboxLineNo=1\relax\slshape\fi%
\ifnum\theVerbboxLineNo=3\relax\slshape\fi%
}
\begin{verbbox}[\formatting]
line1
line2
line3
\end{verbbox}
This is my code: \fbox{\theverbbox}
\renewcommand\formatting{%
\ifnum\theVerbboxLineNo=1\relax\slshape\fi%
\ifnum\theVerbboxLineNo=3\itshape\leavevmode%
\smash{\rlap{\color{red!20}\rule[-\dp\strutbox]{27pt}{\baselineskip}}}\fi%
}
\begin{verbbox}[\formatting]
line1
line2
line3
line4
\end{verbbox}
This is my revised code: \fbox{\theverbbox}
\end{document}