
---
환경 내부를 사용하여 전각 대시를 조판하려고 하는데 alltt
단일 전각 대시 대신 하이픈 3개가 표시됩니다.
MWE
\documentclass[12pt]{article}
\usepackage{alltt}
\begin{document}
Usually, \verb"---" becomes an em dash, i.e. "---", in normal mode.
But in the alltt environment, it becomes three hyphens.
\begin{alltt}
Please---will you give me an em dash?
\end{alltt}
\end{document}
댓글에 대한 응답 의견에서는 왜 고정 폭 환경에서 전각 대시를 조판하고 싶은지 물었습니다. 전각 대시처럼 보이지만 고정 폭 환경에서 두 공백의 길이를 사용하는 대시를 조판하고 싶습니다(예: "--"와 같지만 함께 결합되어 문자와 같은 단일 전각 대시를 형성함).
답변1
내 제안은 em-dash를 가져온 매크로 형식으로 이를 "숨기는" 것입니다 \normalfont
.
\documentclass{article}
\newcommand{\emdash}{{\normalfont ---}}
\usepackage{alltt}
\begin{document}
Usually, \verb"---" becomes an em dash, i.e. ``---'', in normal mode.
But in the alltt environment, it becomes three hyphens.
\begin{alltt}
Please\emdash{}will you give me an em dash?
\end{alltt}
\end{document}
고정 폭 글꼴에 em 대시가 포함되어 있지 않으면 별도의 대시로 설정됩니다. 아마도 다음과 유사한 정의를 사용하여 단일 간격의 em-dash를 강제로 표시할 수 있습니다 \emdash
.
\documentclass{article}
\makeatletter
\newlength{\emdashttlen}
\settowidth{\emdashttlen}{\ttfamily---}
\newcommand{\emdash}{\makebox[\emdashttlen]{-\cleaders\hbox{\hspace{-.45ex}-}\hfill\kern0pt}}
\makeatother
\usepackage{alltt}
\begin{document}
Usually, \verb"---" becomes an em dash, i.e. ``---'', in normal mode.
But in the alltt environment, it becomes three hyphens.
\begin{alltt}
Please---will you give me an em dash?
Please\emdash{}will you give me an em dash?
\end{alltt}
\end{document}
리더에 대한 일부 정보는 다음에서 찾을 수 있습니다.반복되는 문자열로 줄을 채우고 싶습니다..
답변2
간단한 해결책: UTF-8 사용
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{alltt,etoolbox}
\apptocmd{\alltt}{\def\textemdash{{\fontfamily{cmvtt}\selectfont---}}}{}{}
\begin{document}
\begin{alltt}
Please—will you give me an em dash?
Please--will you give me an em dash?
\end{alltt}
\end{document}
첫 번째 줄에는 — (유니코드 U+2014 EM DASH)가 포함되어 있습니다.
더 복잡한 솔루션: ---
다음으로 변환{\fontfamily{cmvtt}\selectfont---}
\documentclass{article}
\usepackage{alltt,etoolbox}
\makeatletter
\begingroup\lccode`~=`-
\lowercase{\endgroup\apptocmd{\alltt}{\let~\alltthyphen}{}{}
\newcommand\alltthyphen{\@ifnextchar~{\@alltthyphen@i}{\char`\- }}
\def\@alltthyphen@i#1{% #1 is -
\@ifnextchar~{{\fontfamily{cmvtt}\selectfont---}\@gobble}{\char`\-\char`\- }%
}}
\makeatother
\begin{document}
\begin{alltt}
Please---will you give me an em dash?
PleaseXXwill you give me an em dash?
\end{alltt}
\end{document}
출력은 이전과 동일합니다.
지나치게 복잡한 솔루션: 글꼴 모음에 가변 폭 타자기 글꼴이 없기 때문에 em-dash를 위조합니다.
\documentclass{article}
\usepackage{alltt,etoolbox}
\usepackage{tgcursor}
\makeatletter
\begingroup\lccode`~=`-
\lowercase{\endgroup\apptocmd{\alltt}{\let~\alltthyphen}{}{}
\newcommand\alltthyphen{\@ifnextchar~{\@alltthyphen@i}{\char`\- }}
\def\@alltthyphen@i#1{% #1 is -
\@ifnextchar~{\fake@em@dash\@gobble}{\char`\-\char`\- }%
}}
\def\fake@em@dash{%
\sbox0{--}%
\makebox[\wd0][s]{-\hss-\hss-}%
}
\makeatother
\begin{document}
\begin{alltt}
Please---will you give me an em dash?
PleaseXXwill you give me an em dash?
\end{alltt}
\end{document}
--
대신에 just를 사용하여 설정을 단순화하고 싶을 수도 있습니다 ---
. 위의 매크로를 변경해야 합니다.