현재 의사 코드의 따옴표는 다음과 같습니다.
프로그래밍 환경에 더 가깝고 MS Word로 방금 입력한 것 같지 않은 인용문을 어떻게 얻을 수 있습니까?
MWE
\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
\usepackage{amssymb,amsmath,amsfonts} % nice math rendering
\usepackage{algorithm,algpseudocode}
\begin{document}
\begin{preview}
This is a 'samle' with some "quotes".
\begin{algorithm}[H]
\begin{algorithmic}
\State $a \gets \Call{map}{~}$
\State $a['x'] \gets 42$
\State $a["x"] \gets 1337$
\end{algorithmic}
\caption{Algorithmus von Stoer und Wanger}
\label{alg:seq1}
\end{algorithm}
\end{preview}
\end{document}
관련 질문
다른 환경에 대한 질문은 이미 답변되었습니다.
- 직선 따옴표?
\textquotedbl
: 및 를 사용하여 직선 인용을 얻을 수 있는 것처럼 보이지만\textquotesingle
의사 코드를 조작할 필요 없이 모든 알고리즘 환경에 대해 직선 인용을 원합니다. - Consolas: 직선 인용문: 목록용입니다.
- 목록에서 곧은 큰따옴표를 어떻게 얻을 수 있나요?
- 탭으로 된 직선 따옴표
답변1
몇 가지 트릭을 사용한다면 직선 따옴표를 가질 수 있습니다.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{textcomp}
\usepackage{amssymb,amsmath,amsfonts}
\usepackage{algorithm,algpseudocode}
\usepackage{etoolbox} % for the trick
% setup algorithmic to use straight quotes
\AtBeginEnvironment{algorithmic}{\useupquotes}
% define the command that activates the quotes and redefines them
\newcommand{\useupquotes}{%
\begingroup\lccode`\~=`\'\lowercase{\endgroup\let~}\algoupquote
\begingroup\lccode`\~=`\"\lowercase{\endgroup\let~}\algoupquotes
\catcode`\'=\active\catcode`\"=\active
}
% Customize here (\mbox is necessary because of math mode;
% if needed in subscripts, use \text instead)
\newcommand{\algoupquote}{\mbox{\textquotesingle}}
\newcommand{\algoupquotes}{\mbox{\char`\"}}
\begin{document}
Look at Algorithm~\ref{some} for seeing the quotes.
\begin{algorithm}[htp]
\begin{algorithmic}
\State $a['x'] \gets 42$
\State $a["x"] \gets 1337$
\end{algorithmic}
\caption{Some algorithm}\label{some}
\end{algorithm}
\end{document}
답변2
다음은 를 사용하는 활성 문자 접근 방식입니다 textcomp
.
\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
\usepackage{amssymb,amsmath,amsfonts} % nice math rendering
\usepackage{algorithm,algpseudocode}
\usepackage{textcomp}
\let\svalgorithm\algorithm
\catcode`'=\active
\catcode`"=\active
\def\quoteactive{\catcode`'=\active\def'{\makebox{\textquotesingle}}}
\def\qquoteactive{\catcode`"=\active\def"{\makebox{\textquotedbl}}}
\catcode`'=12
\catcode`"=12
\def\algorithm{\quoteactive\qquoteactive\svalgorithm}
\begin{document}
\begin{preview}
This is a 'sample' with some "quotes"{} or ``quotes''.
\begin{algorithm}[H]
\begin{algorithmic}
\State $a \gets \Call{map}{~}$
\State $a['x'] \gets 42$
\State $a["x"] \gets 1337$
\end{algorithmic}
\caption{Algorithmus von Stoer und Wanger}
\label{alg:seq1}
\end{algorithm}
Restored? ' and ", ``quotations'' or `quotations'
\end{preview}
\end{document}
답변3
인용문을 활성화할 수도 있지만 매크로로 묶는 것이 좋습니다(참조는 다음에서 제공됩니다).직선 따옴표?):
\documentclass{article}
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
\usepackage{textcomp}
\usepackage{amssymb,amsmath,amsfonts} % nice math rendering
\usepackage{algorithm,algpseudocode}
\makeatletter
\newcommand{\upquotetype}{}
\newcommand{\upquote@aux}[1]{\text{\upquotetype}#1\text{\upquotetype}}
\newcommand{\upquotesingle}{\renewcommand{\upquotetype}{\textquotesingle}\upquote@aux}
\newcommand{\upquotedouble}{\renewcommand{\upquotetype}{\textquotedbl}\upquote@aux}
\begin{document}
This is a 'sample' with some "quotes".
\begin{algorithm}[H]
\begin{algorithmic}
\State $a[\upquotesingle{x}] \gets 42$
\State $a[\upquotedouble{x}] \gets 1337$
\end{algorithmic}
\caption{Some algorithm}
\end{algorithm}
\end{document}