![为跨多页的带框引文添加标题和“续”](https://linux22.com/image/271885/%E4%B8%BA%E8%B7%A8%E5%A4%9A%E9%A1%B5%E7%9A%84%E5%B8%A6%E6%A1%86%E5%BC%95%E6%96%87%E6%B7%BB%E5%8A%A0%E6%A0%87%E9%A2%98%E5%92%8C%E2%80%9C%E7%BB%AD%E2%80%9D.png)
我必须在论文中附上我所进行的采访记录,而我将向其提交论文的机构施加了一些限制。规则如下:
- 摘录内容应加框。
- 当文本跨越多页时,应将每个部分单独框起来。
- 同一对话的各个片段应具有相同的标题,并且每个片段后面都应有短语“继续”,当然最后一个片段除外。
我尝试了该mframed
包,但它没有绘制框架的下/上边界,所以我选择了framed
可以解决问题的包。我还选择了dialogue
环境quote
。quotation
我还是不知道该怎么做
- 插入标题,因为这不是浮动,将其设为浮动可以防止分页
- 对每个部分应用相同的标题,因此也应用相同的对话编号
- 让 LaTeX 在每部分后写上“con.”(续)
下面是我编写的最小工作示例的图片。我通过图片编辑添加了“cont.”来显示它应该是什么样子(没有标题)。
用于产生上述输出的代码是:
\documentclass[a4paper,onesided,12pt]{report}
\usepackage[utf8x]{inputenc}
\renewcommand{\labelenumi}{(\roman{enumi})}
\usepackage{cite}
\usepackage{framed}
\usepackage{lipsum}
\usepackage{dialogue}
\begin{document}
\lipsum[1-2]
\begin{framed}
\begin{dialogue}
\speak{The Researcher} If you were a teacher, how would you teach physics?
A few seconds of silence
\speak{The Researcher} Have you ever thought, ugh this is boring, I wish it were more like this…
\speak{Student 1} It would probably be more experiment-oriented. I would conduct more experiments.
\speak{Student 2} I would just write on the board like the usual.
\speak{Student 1} Because when it is visual… I would choose to teach using experiments because since experiments are visual they are better able to maintain students’ attention.
\speak{Student 3} I would probably use analogies, you know like with electromagnetic waves. Or mechanics perhaps. I don’t know which type of wave sound waves are at the present, like those that require a medium or those that do not, I would say something like, I would tell them for instance to consider sound, is sound mechanical?
\speak{Student 2} Right.
\speak{Student 3} ????? I would get them to remember by doing that, like when they think of sound , it requires a medium for propogation, and thus they would understand the properties of mechanical waves. I would do such things.
\speak{Student 2} I would simply teach by writing on the board, this is the way I learn. I do not like to use visual materials that much.
\speak{Student 4} I would write the summary on the board, and go on that when teaching.
\speak{Student 5} Actually it is good to write…
\speak{Student 2} I would give pointers; which topics produce more questions, how to solve them…
\speak{Student 5} Our elementary school teacher would give us two weeks to copy a 30-40 page material to paper, since it is easier to remember when you write it. It helped better commit that subject to memory since we also covered the same material in class, but it was boring since you listen to the same things that you wrote down, it was not fun.
\speak{The Researcher} Was copying it to your notebook enough to help you understand it fully that you got bored in class?
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\end{dialogue}
\end{framed}
\end{document}
答案1
更新:
使用tcolorbox
包,现在有一个完整的解决方案;myexcerpt
环境有两个强制参数:第一个用于标题,第二个用于最终交叉引用的标签(示例说明了这一点)。所有要求均已满足:
文本被框架化:如果出现分页符,则拆分框架的每个部分都将被完全框架化。
对于分割框架,除最后一个部分外,所有部分都在底部接收“cont.”文本(规定不超过底部边距)。
框架可以接收带有标签和自动编号的标题;标题文本出现在框架的顶部;对于分割框架,标题出现在每个分割部分的顶部。
代码:
\documentclass[a4paper,12pt]{report}
\usepackage[utf8x]{inputenc}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage{ragged2e}
\usepackage{dialogue}
\usepackage{chngcntr}
\usetikzlibrary{calc}
\newcounter{exc}
\counterwithin{exc}{chapter}
\newlength\CapHt
\newlength\CapDp
\newcommand\excerptname{Excerpt}
\newcommand\exccaptionfont{\normalfont\small}
\newtcolorbox{myexcerpt}[2]{%
breakable,
enhanced,
freelance,
frame code={
\draw[line width=1pt]
([yshift=1pt]interior.north west-|frame.north west) --
([yshift=1pt]interior.north east-|frame.north east) --
(frame.south east) --
(frame.south west) --
cycle;
},
colback=white,
top=4mm,
arc=0pt,
outer arc=0pt,
pad at break=2mm,
fontupper=\normalsize,
coltitle=black,
fonttitle=\normalfont\small,
step and label={exc}{#2},
title={\noindent\justifying\excerptname~\theexc: #1},
title after break={\noindent\justifying\excerptname~\theexc: #1},
overlay middle={%
\node[
inner xsep=0pt,
anchor=north east,
font=\footnotesize\color{red}]
at (frame.south east) {cont.};
},
overlay first={%
\node[
inner xsep=0pt,
anchor=north east,
font=\footnotesize\color{red}]
at (frame.south east) {cont.};
},
enlarge top by=\topskip,
enlarge top at break by=0pt,
enlarge bottom at break by=\baselineskip,
}
\begin{document}
\chapter{Test Chapter}
Some cross-references to the dialogues~\ref{exc:long} and~\ref{exc:short}
\lipsum[2]
\begin{myexcerpt}{some text that will be used for the caption of this long dialogue and we add some additional test text}{exc:long}
\begin{dialogue}
\speak{The Researcher} If you were a teacher, how would you teach physics?
A few seconds of silence
\speak{The Researcher} Have you ever thought, ugh this is boring, I wish it were more like this…
\speak{Student 1} It would probably be more experiment-oriented. I would conduct more experiments.
\speak{Student 2} I would just write on the board like the usual.
\speak{Student 1} Because when it is visual… I would choose to teach using experiments because since experiments are visual they are better able to maintain students’ attention.
\speak{Student 3} I would probably use analogies, you know like with electromagnetic waves. Or mechanics perhaps. I don’t know which type of wave sound waves are at the present, like those that require a medium or those that do not, I would say something like, I would tell them for instance to consider sound, is sound mechanical?
\speak{Student 2} Right.
\speak{Student 3} ????? I would get them to remember by doing that, like when they think of sound , it requires a medium for propogation, and thus they would understand the properties of mechanical waves. I would do such things.
\speak{Student 2} I would simply teach by writing on the board, this is the way I learn. I do not like to use visual materials that much.
\speak{Student 4} I would write the summary on the board, and go on that when teaching.
\speak{Student 5} Actually it is good to write…
\speak{Student 2} I would give pointers; which topics produce more questions, how to solve them…
\speak{Student 5} Our elementary school teacher would give us two weeks to copy a 30-40 page material to paper, since it is easier to remember when you write it. It helped better commit that subject to memory since we also covered the same material in class, but it was boring since you listen to the same things that you wrote down, it was not fun.
\speak{The Researcher} Was copying it to your notebook enough to help you understand it fully that you got bored in class?
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\end{dialogue}
\end{myexcerpt}
\lipsum[4]
\begin{myexcerpt}{this is the description of the second dialogue}{exc:short}
\begin{dialogue}
\speak{The Researcher} If you were a teacher, how would you teach physics?
A few seconds of silence
\speak{The Researcher} Have you ever thought, ugh this is boring, I wish it were more like this…
\speak{Student 1} It would probably be more experiment-oriented. I would conduct more experiments.
\speak{Student 2} I would just write on the board like the usual.
\speak{Student 1} Because when it is visual… I would choose to teach using experiments because since experiments are visual they are better able to maintain students’ attention.
\end{dialogue}
\end{myexcerpt}
\end{document}
以下代码是第一个提出的解决方案。由于标题出现在框架内,因此它仍然不完美。所需的修改并不那么困难,但我将保留其当前形式(暂时),因为我已经为这个问题投入了足够的时间。
您可以使用mdframed
包;它的firstextra
和middleextra
键允许您在所需位置添加所需帧的“cont.”文本;我还定义了一个新的 mdf 键,允许您传递标题;环境会自动Excerpt <number>:
在实际标题文本前添加标签;<number>
是形式为的字符串<chapter number>.<excerpt number>
;每个新章节重置的exc
计数器:<excerpt number>
\documentclass[a4paper,onesided,12pt]{report}
\usepackage[utf8x]{inputenc}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}
\usepackage{dialogue}
\usepackage{chngcntr}
\newcounter{exc}
\counterwithin{exc}{chapter}
\newcommand\excerptname{Excerpt}
\makeatletter
% mdf key for the caption
\def\mdf@@caption{}
\define@key{mdf}{caption}{\def\mdf@@caption{#1}}
\newmdenv[
settings={\refstepcounter{exc}},
everyline=true,
linewidth=1pt,
repeatframetitle=true,
frametitle={%
\ifdefempty{\mdf@@caption}{}
{\excerptname~\theexc:~\mdf@@caption}%
},
frametitlefont=\normalfont\small,
firstextra={%
\node[fill=white,anchor=east,inner xsep=0pt,yshift=-10pt,
font=\footnotesize\color{red}]
at (P|-O) {cont.};%
},
middleextra={%
\node[fill=white,anchor=east,inner xsep=0pt,yshift=-10pt,
font=\footnotesize\color{red}]
at (P|-O) {cont.};%
},
]{myexcerpt}
\makeatother
\begin{document}
\chapter{Test Chapter}
\lipsum[2-5]
\begin{myexcerpt}[caption={this is the description of this dialogue; it is a little long just for this example so that it spans two lines}]
\begin{dialogue}
\speak{The Researcher} If you were a teacher, how would you teach physics?
A few seconds of silence
\speak{The Researcher} Have you ever thought, ugh this is boring, I wish it were more like this…
\speak{Student 1} It would probably be more experiment-oriented. I would conduct more experiments.
\speak{Student 2} I would just write on the board like the usual.
\speak{Student 1} Because when it is visual… I would choose to teach using experiments because since experiments are visual they are better able to maintain students’ attention.
\speak{Student 3} I would probably use analogies, you know like with electromagnetic waves. Or mechanics perhaps. I don’t know which type of wave sound waves are at the present, like those that require a medium or those that do not, I would say something like, I would tell them for instance to consider sound, is sound mechanical?
\speak{Student 2} Right.
\speak{Student 3} ????? I would get them to remember by doing that, like when they think of sound , it requires a medium for propogation, and thus they would understand the properties of mechanical waves. I would do such things.
\speak{Student 2} I would simply teach by writing on the board, this is the way I learn. I do not like to use visual materials that much.
\speak{Student 4} I would write the summary on the board, and go on that when teaching.
\speak{Student 5} Actually it is good to write…
\speak{Student 2} I would give pointers; which topics produce more questions, how to solve them…
\speak{Student 5} Our elementary school teacher would give us two weeks to copy a 30-40 page material to paper, since it is easier to remember when you write it. It helped better commit that subject to memory since we also covered the same material in class, but it was boring since you listen to the same things that you wrote down, it was not fun.
\speak{The Researcher} Was copying it to your notebook enough to help you understand it fully that you got bored in class?
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\speak{Student 5} You do understand it.
\speak{Student 2} If visual materials, slides or experiments are to be used we have to study daily for us to remember. Yet I forget since I do not study daily.
\end{dialogue}
\end{myexcerpt}
\lipsum[4]
\begin{myexcerpt}[caption={this is the description of the second dialogue}]
\begin{dialogue}
\speak{The Researcher} If you were a teacher, how would you teach physics?
A few seconds of silence
\speak{The Researcher} Have you ever thought, ugh this is boring, I wish it were more like this…
\speak{Student 1} It would probably be more experiment-oriented. I would conduct more experiments.
\speak{Student 2} I would just write on the board like the usual.
\speak{Student 1} Because when it is visual… I would choose to teach using experiments because since experiments are visual they are better able to maintain students’ attention.
\end{dialogue}
\end{myexcerpt}
\end{document}