Courier 字体导致行溢出

Courier 字体导致行溢出

我想使用 Courier 字体来举例,但是它会导致行溢出......

我正在使用以下代码:

\usepackage{courier}

\begin{document}

\section{Introduction}
RE is a task of extracting relations among lexical components in natural language 
text. This paper focuses on extracting binary relations between two entities in a 
sentence. The following is an example Wikipedia sentence with two named-entities 
annotated:\\

\texttt{"Knockin' on Heaven's Door" is a song written and sung by Bob Dylan, 
for the soundtrack of the 1973 film Pat Garrett and Billy the Kid.}\\

In the example sentence above, \textit{Knockin' on Heaven's Door} and 
\textit{Bob Dylan} are annotated as named-entities. Then two DBpedia properties, 
\textit{dbo:composer} (from e1 to e2) and \textit{dbo:musicBy} (from e1 to e2), 
can be extracted as relations between the entity pair.

\end{document}

在下面的屏幕截图中,示例行(Courier 字体)到达右边距。(“by”超出了正文!)

在此处输入图片描述

我希望例句适合正文,而不是延伸到页边距。我该如何解决这个问题?

答案1

quote环境是在 LaTeX 内核中定义的,因此会议模板不允许使用它的可能性很小。

我提出了三种解决方案;每一种解决方案都按其应有的环境形式来实现。

请注意\\绝不应该用于结束段落,并且绝不应该在空白行之前使用。如果您想“留下垂直空白空间”,请使用\vspace或 的适当方法\addvspace

\documentclass{article}
\usepackage{courier}

\newenvironment{ttquote}
 {\quote\ttfamily\raggedright}
 {\endquote}

\newenvironment{ttquotejustify}
 {\par\addvspace{\topsep}%
  \ttfamily\setlength{\spaceskip}{0.3em plus 0.3em}%
  \noindent\ignorespaces}
 {\par\addvspace{\topsep}\ignorespacesafterend}

\newenvironment{ttquotesmall}
 {\quote\ttfamily\raggedright\small}
 {\endquote}

\begin{document}

\section{Introduction}
RE is a task of extracting relations among lexical components in natural language 
text. This paper focuses on extracting binary relations between two entities in a 
sentence. The following is an example Wikipedia sentence with two named-entities 
annotated:
\begin{ttquote}
"Knockin' on Heaven's Door" is a song written and sung by Bob Dylan, 
for the soundtrack of the 1973 film Pat Garrett and Billy the Kid.
\end{ttquote}
In the example sentence above, \textit{Knockin' on Heaven's Door} and 
\textit{Bob Dylan} are annotated as named-entities. Then two DBpedia properties, 
\textit{dbo:composer} (from e1 to e2) and \textit{dbo:musicBy} (from e1 to e2), 
can be extracted as relations between the entity pair.
\begin{ttquotejustify}
"Knockin' on Heaven's Door" is a song written and sung by Bob Dylan, 
for the soundtrack of the 1973 film Pat Garrett and Billy the Kid.
\end{ttquotejustify}
In the example sentence above, \textit{Knockin' on Heaven's Door} and 
\textit{Bob Dylan} are annotated as named-entities. Then two DBpedia properties, 
\textit{dbo:composer} (from e1 to e2) and \textit{dbo:musicBy} (from e1 to e2), 
can be extracted as relations between the entity pair.
\begin{ttquotesmall}
"Knockin' on Heaven's Door" is a song written and sung by Bob Dylan, 
for the soundtrack of the 1973 film Pat Garrett and Billy the Kid.
\end{ttquotesmall}
In the example sentence above, \textit{Knockin' on Heaven's Door} and 
\textit{Bob Dylan} are annotated as named-entities. Then two DBpedia properties, 
\textit{dbo:composer} (from e1 to e2) and \textit{dbo:musicBy} (from e1 to e2), 
can be extracted as relations between the entity pair.

\end{document}

第三个解决方案使用 ,\small这样文本就不那么突出了;它已经通过缩小边距和使用等宽字体排版来强调了。如果您喜欢它,但也想要对齐,请在定义中将其更改\raggedright\setlength{\spaceskip}{0.3em plus 0.3em}

第二种解决方案展示了如何定义自己的环境,这是quote不允许的。当然,混合这三种方法是可能的。

在此处输入图片描述

已添加svproc

ttquote这是对两侧缩进并对齐文本的定义。

\documentclass{svproc}
\usepackage{courier}

\newenvironment{ttquote}
 {\list{}{\rightmargin=\leftmargin\rightskip=0pt}%
  \ttfamily\setlength\spaceskip{0.3em plus 0.3em}%
  \item\relax}
 {\endlist}

\begin{document}

\section{Introduction}
RE is a task of extracting relations among lexical components in natural language 
text. This paper focuses on extracting binary relations between two entities in a 
sentence. The following is an example Wikipedia sentence with two named-entities 
annotated:
\begin{ttquote}
"Knockin' on Heaven's Door" is a song written and sung by Bob Dylan, 
for the soundtrack of the 1973 film Pat Garrett and Billy the Kid.
\end{ttquote}
In the example sentence above, \textit{Knockin' on Heaven's Door} and 
\textit{Bob Dylan} are annotated as named-entities. Then two DBpedia properties, 
\textit{dbo:composer} (from e1 to e2) and \textit{dbo:musicBy} (from e1 to e2), 
can be extracted as relations between the entity pair.

\end{document}

在此处输入图片描述

答案2

请不要用于\\段落分隔!


https://tex.stackexchange.com/a/368344/36296

\documentclass{article}

\usepackage{courier}

\begin{document}

\section{Introduction}
RE is a task of extracting relations among lexical components in natural language 
text. This paper focuses on extracting binary relations between two entities in a 
sentence. The following is an example Wikipedia sentence with two named-entities 
annotated:

\bigskip
\texttt{\spaceskip=.3em plus 0.2em minus .1em "Knockin' on Heaven's Door" is a song written and sung by Bob Dylan, 
for the soundtrack of the 1973 film Pat Garrett and Billy the Kid.}
\bigskip

In the example sentence above, \textit{Knockin' on Heaven's Door} and 
\textit{Bob Dylan} are annotated as named-entities. Then two DBpedia properties, 
\textit{dbo:composer} (from e1 to e2) and \textit{dbo:musicBy} (from e1 to e2), 
can be extracted as relations between the entity pair.

\end{document}

在此处输入图片描述

相关内容