
특별한 키워드를 추가하는 방법을 알고 싶습니다.무시됨그 안에 패키지 \lstinputlisting
에 사용됩니다 listings
.
스크린 샷은 내 문제를 보여줍니다. 나는 ROOT 데이터 분석 프레임워크의 튜토리얼 문서를 작성 중입니다(https://root.cern.chroot [n]
)에는 아래와 같은 사용자 프롬프트가 있는 자체 C++ 인터프리터가 있습니다 .
대부분의 경우 lstlisting
환경과 c++
옵션을 사용하면 ROOT 인터프리터에서 제대로 작동합니다. 하지만 root (cont'ed, cancel with .@)
인터프리터에서 이 메시지에 인쇄되면 이 메시지의 작은따옴표는 C 문자열의 시작으로 간주되어 코드 색상이 녹색으로 변경됩니다.
\begin{lstlisting}[language=c++,breaklines=true]
root [0] TH2D* h2 = new TH2D("h2", "2D Gaussian Distribution;#it{x};#it{y};Entries", 100, -10, 10, 100, -10, 10)
(TH2D *) 0x7fe8c3615eb0
root [1] const Double_t kSigma = 2.
(const Double_t) 2.00000
root [2] for(Int_t i = 0; i < 100000; i++){
root (cont'ed, cancel with .@) [3] Double_t x = gRandom->Gaus(0, kSigma);
root (cont'ed, cancel with .@) [4] Double_t y = gRandom->Gaus(0, kSigma);
root (cont'ed, cancel with .@) [5] h2->Fill(x, y);
root (cont'ed, cancel with .@) [6] }
root [7] TCanvas* can = new TCanvas("can", "can", 600, 600)
(TCanvas *) 0x7fe8c359a9a0
root [8] h2->Draw("colz")
\end{lstlisting}
listings
이 작은따옴표를 무시하도록 패키지 에 명령하는 방법을 알고 싶습니다 . cont'ed
"무시" 목록과 같은 항목에 문자열을 추가할 수 있는 방법이 있나요 ?
답변1
를 사용하는 임시 솔루션을 찾았 mathescape
지만 여전히 더 나은 솔루션을 찾고 있습니다.
\newcommand{\conted}{\texttt{cont'ed}} % for ROOT 6 prompt
\begin{lstlisting}[language=c++,breaklines=true,mathescape]
root [0] TH2D* h2 = new TH2D("h2", "2D Gaussian Distribution;#it{x};#it{y};Entries", 100, -10, 10, 100, -10, 10)
(TH2D *) 0x7fe8c3615eb0
root [1] const Double_t kSigma = 2.
(const Double_t) 2.00000
root [2] for(Int_t i = 0; i < 100000; i++){
root ($\conted$, cancel with .@) [3] Double_t x = gRandom->Gaus(0, kSigma);
root ($\conted$, cancel with .@) [4] Double_t y = gRandom->Gaus(0, kSigma);
root ($\conted$, cancel with .@) [5] h2->Fill(x, y);
root ($\conted$, cancel with .@) [6] }
root [7] TCanvas* can = new TCanvas("can", "can", 600, 600)
(TCanvas *) 0x7fe8c359a9a0
root [8] h2->Draw("colz")
\end{lstlisting}