我正在使用 TeX 写一本小说。我需要将对话行从左边距缩进 0.25 英寸,从右边距缩进 1 英寸。我曾考虑使用minipage
来完成此操作,因为对话需要延伸到多行文本。另一种方法是使用命令\quotation
。但是,我需要经常使用此命令,并且我正在寻找一种简单的方法来实现这一点。 minipage 命令可以放在全局命令中吗?或者\quotation
就此而言?
\d
如果能够在代码中写一些类似的东西,而不是每次需要包含对话时都必须写出冗长的命令结构,那就太好了。
我将非常感激任何帮助/建议!Mike
答案1
我建议使用另一种解决方案,即使用该enumitem
包。更准确地说,有两种变体,不知道您的对话框是以破折号开头还是仅使用引号。在这种情况下,我反对使用命令,因为这种命令的参数可能相当长,而且很容易忘记右括号。相反,我建议使用快捷方式进入和离开环境。请注意,对话框的不同“部分”由\item
(或别名)引入。
这是一个‘真实’的例子(来自爱德华·利尔):
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{ebgaramond}
\usepackage{enumitem}
\newlist{dialogdash}{description}{1}
\setlist[dialogdash]{labelindent = 0.25in, leftmargin = \labelindent, labelsep = 0.2em, rightmargin = 1in, nosep,topsep = 0.5ex, itemsep = 0.5ex, align = left}
\newenvironment{dlgdash}{\begin{dialogdash}\item[---]}{\end{dialogdash}}
\newlist{dialognodash}{itemize}{1}
\setlist[dialognodash]{label = ,labelindent = 0.25in, leftmargin = \labelindent, rightmargin = 1in, nosep, topsep = 0.5ex, itemsep = 0.5ex, align = left}
\newenvironment{dlgnodash}{\begin{dialognodash}\item }{\end{dialognodash}}
\def\bdlg{\begin{dlgnodash}}
\def\edlg{\end{dlgnodash}}
\parindent=0pt
\begin{document}
The Four Children then entered into conversation with the Blue Bottle-Flies, who discoursed in a placid and genteel manner, though with a slightly buzzing accent, chiefly owing to the fact that they each held a small clothes-brush between their teeth which naturally occasioned a fizzy extraneous utterance.
\begin{dlgdash}
Why, said Violet, would you kindly inform us, do you reside in bottles? and if in bottles at all, why not rather in green or purple, or indeed in yellow bottles?
\end{dlgdash}
To which questions a very aged Blue-Bottle-Fly answered,
\bdlg
‘We found the bottles here all ready to live in, that is to say, our great-great-great-great-great-grandfathers did, so we occupied them at once. And when the winter comes on, we turn the bottles upside down, and consequently rarely feel the cold at all, and you know very well that this could not be the case with bottles of any other colour than blue.’
\item ‘Of course it could not;’ said Slingsby, ‘but if we may take the liberty of inquiring, on what do you chiefly subsist?’
\item ‘Mainly on Oyster-patties,’ said the Blue-Bottle-Fly, ‘and, when these are scarce, on Raspberry vinegar and Russian leather boiled down to a jelly.’
\item ‘How delicious!’ said Guy.
\edlg
\end{document}
答案2
我需要将对话行从左边距缩进 0.25 英寸,从右边距缩进 1 英寸
这听起来像是 KOMA-Script 环境的工作addmargin
(可通过scrextend
包在其他类中使用)。环境是一个内部类似于quotation
环境的列表。它允许使用强制参数从两侧设置自定义缩进。使用可选参数可以为左侧的缩进选择不同的值:
\begin{addmargin}[<left indent>]{<indent>}
这可以很容易地包装在自定义命令中
\newcommand\dialogue[1]{%
\begin{addmargin}[.25in]{1in}
#1%
\end{addmargin}%
}
或自定义环境:
\newenvironment{dialogue}
{\addmargin[.25in]{1in}}
{\endaddmargin}
一个例子:
\documentclass{article}
\usepackage{scrextend}% not needed with a KOMA-Script class
\newenvironment{dialogue}
{\addmargin[.25in]{1in}}
{\endaddmargin}
\usepackage{lipsum}% dummy text
\begin{document}
\lipsum[1]
\begin{dialogue}
\lipsum[2]
\end{dialogue}
\lipsum[3]
\begin{dialogue}
\lipsum[4]
\end{dialogue}
\lipsum[5]
\end{document}
答案3
与 KOMA 相关的答案类似,有一个memoir
相关的答案:
\documentclass[12]{article}
\usepackage[showframe]{geometry}% to visualize output
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage[strict]{changepage}% <-- or use the memoir class
\newenvironment{dial}
{\begin{adjustwidth}{0.25in}{1in}
% other commands?
\small
\parindent 0pt%
\parskip 3pt%
}
{\end{adjustwidth}}
\begin{document}
\lipsum[1]
\begin{dial}
\lipsum[2-4]
\end{dial}
\lipsum[5]
\end{document}