목록의 역 악센트 또는 억음 악센트

목록의 역 악센트 또는 억음 악센트

예를 들어 bash 스크립트를 표시하기 위해 목록을 사용하고 있습니다.

$ export MY_ENV=`pwd`

목록에 `에 대한 올바른 문자가 표시되도록 하려면 어떻게 해야 합니까? 지금은 '

MWE:

\documentclass[11pt, article, oneside, a4paper]{memoir}

% Files encoding
\usepackage[utf8]{inputenc}
\usepackage[spanish, es-noquoting, es-tabla]{babel}
%es-noquoting era por el tikz

\usepackage[spanish]{translator}
\usepackage[OT1]{fontenc}
%\usepackage[T1]{fontenc}

%Listings
\usepackage[final]{listings} % to be shown independently draft of final
\lstdefinestyle{CommandLineStyle}{
  basicstyle=\small\ttfamily,
  numbers=none,
%  frame=tblr,
  columns=fullflexible,
%  backgroundcolor=\color{blue!10},
  linewidth=0.95\linewidth,
  xleftmargin=0.05\linewidth,
  breaklines=true,
  breakindent=1em,
%  inputencoding=utf8/latin1,
%  postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
%  breakautoindent=true
}

\begin{document}

\begin{lstlisting}[style=CommandLineStyle]
$ export MY_ENV=`pwd`
\end{lstlisting}


\end{document}

답변1

패키지 는 왼쪽 및 오른쪽 인용문이 인쇄되는 방식을 결정하는 토글 옵션을 listings제공합니다 . upquote이를 설정하면 true원하는 작업이 수행됩니다(egreg의 답변에서와 같이 읽기 능력을 설정하는 것과 유사하게 작동합니다). textcomp옵션을 설정하기 전에 패키지를 로드해야 합니다 .

\documentclass[article]{memoir}

\usepackage{textcomp} % <--- for other glyphs, so can use upquote option of listings

\usepackage[final]{listings} % to be shown independently draft of final
\lstdefinestyle{CommandLineStyle}{
  basicstyle=\small\ttfamily,
  numbers=none,
  upquote=true% ensure that backtick displays correctly
}

\begin{document}

\begin{lstlisting}[style=CommandLineStyle]
$ export MY_ENV=`pwd`
\end{lstlisting}

\end{document}

백틱이 올바르게 표시됩니다.

답변2

literate의 기능 listings\textasciigrave매크로를 사용할 수 있습니다 textcomp. 예제를 필수로 줄였습니다.

\documentclass[article]{memoir}

\usepackage{textcomp} % <--- for other glyphs

\usepackage[final]{listings} % to be shown independently draft of final
\lstdefinestyle{CommandLineStyle}{
  basicstyle=\small\ttfamily,
  numbers=none,
%  frame=tblr,
  columns=fullflexible,
%  backgroundcolor=\color{blue!10},
  linewidth=0.95\linewidth,
  xleftmargin=0.05\linewidth,
  breaklines=true,
  breakindent=1em,
%  inputencoding=utf8/latin1,
%  postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
%  breakautoindent=true,
  literate={`}{\textasciigrave}{1}, <--- real back quote
}

\begin{document}

\begin{lstlisting}[style=CommandLineStyle]
$ export MY_ENV=`pwd`
\end{lstlisting}

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

하지만 Bash를 사용하고 있다면 어떨까요?

export MY_ENV=$(pwd)

어느 것이 인쇄하기도 더 간단합니까?;-)

관련 정보