剧本文本注释的方括号边框

剧本文本注释的方括号边框

我想放一个方括号边框围绕段落中的一些单词,并围绕整个居中段落,具体取决于段落宽度。示例:

括号边框示例


在此处输入图片描述

段落中的分页符必须通过将括号边框“切割”成两部分来处理。

我发现了一些例子tikz和完成framed。也许可以使用这种方法?

还有其他想法吗?

答案1

我想我已经满足了你的所有要求:

在此处输入图片描述

我创建了一个\newcommand叫做\annot(用于注释,因为文本看起来像剧本或戏剧文本)的函数。你只需要输入\annot{the text you want to put in the annotation},它就会生成方括号、内部居中和外部居中(如果注释中任何一行的长度大于 4 厘米)。注释中的最大宽度为 13 厘米,然后它会跳过该行(如果你还没有手动执行此操作)。

\annot可以在页面末尾拆分,将方括号“切成”两部分。但这个系统并不完美。它的工作原理如下:

多线,1 条或多条 13 厘米长的线分割良好: 在此处输入图片描述

多行文字中所有小于 13 厘米的行都无法保留,hbox因此括号不会根据文本进行调整,但是也可以很好地拆分:

在此处输入图片描述

如果您有一个简短的注释(<= 4cm),后面跟着普通文本,例如(“Zum Neger”。Ab!)。您只需将文本放在第二对花括号中:\annot{Zum Neger}{Ab!}

代码:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[german,activeacute]{babel}

\usepackage{varwidth}
\usepackage[many]{tcolorbox}

\tcbset{
    bracketstyle/.style={fonttitle=\bfseries, breakable, freelance, colback=white, colframe=white,
    toprule=0pt, bottomrule=0pt, boxrule=0pt, halign=center}
}

\tcbset{
    mstyle/.style={
    bracketstyle, 
    text width=13cm,
    overlay unbroken and first={
        \draw[black!65!white,line width=0.7pt]
        ([yshift=-5pt,xshift=18pt]frame.north west) -- 
        ([yshift=-5pt,xshift=14pt]frame.north west) -- 
        ([yshift=5pt,xshift=14pt]frame.south west);
        \draw[black!65!white,line width=0.7pt]
        ([yshift=-5pt,xshift=-18pt]frame.north east) -- 
        ([yshift=-5pt,xshift=-14pt]frame.north east) -- 
        ([yshift=5pt,xshift=-14pt]frame.south east);
    },
    overlay unbroken app={
        \draw[black!65!white,line width=0.7pt,line cap=rect]
        ([yshift=5pt,xshift=18pt]frame.south west) -- 
        ([yshift=5pt,xshift=14pt]frame.south west);
        \draw[black!65!white,line width=0.7pt,line cap=rect]
        ([yshift=5pt,xshift=-18pt]frame.south east) -- 
        ([yshift=5pt,xshift=-14pt]frame.south east);
    },
    overlay middle and last={
        \draw[black!65!white,line width=0.7pt]
        ([yshift=-5pt,xshift=14pt]frame.north west) -- 
        ([yshift=5pt,xshift=14pt]frame.south west);
        \draw[black!65!white,line width=0.7pt]
        ([yshift=-5pt,xshift=-14pt]frame.north east) -- 
        ([yshift=5pt,xshift=-14pt]frame.south east);
    },
    overlay last app={
        \draw[black!65!white,line width=0.7pt,line cap=rect]
        ([yshift=5pt,xshift=14pt]frame.south west) --
        ([yshift=5pt,xshift=18pt]frame.south west);
        \draw[black!65!white,line width=0.7pt,line cap=rect]
        ([yshift=5pt,xshift=-18pt]frame.south east) --
        ([yshift=5pt,xshift=-14pt]frame.south east);
    }   
}
}

\newtcolorbox{mannot}{
    mstyle
}

\newtcolorbox{lmannot}{
    mstyle, hbox,  left=14pt, right=14pt
}

\newtcolorbox{sannot}[1]{
    bracketstyle,
    hbox, 
    overlay unbroken={
        \draw[black!65!white,line width=0.7pt]
        ([yshift=-5pt,xshift=16pt]frame.north west) -- 
        ([yshift=-5pt,xshift=12pt]frame.north west) -- 
        ([yshift=5pt,xshift=12pt]frame.south west) --
        ([yshift=5pt,xshift=16pt]frame.south west);
        \draw[black!65!white,line width=0.7pt]
        ([yshift=-5pt,xshift=-16pt]frame.north east) -- 
        ([yshift=-5pt,xshift=-12pt]frame.north east) -- 
        ([yshift=5pt,xshift=-12pt]frame.south east) node [yshift=0.315cm,black,right] {#1} --
        ([yshift=5pt,xshift=-16pt]frame.south east) ;
    }
}

\newcommand{\annot}[2]{
\sbox0{#1}  
\ifdim\wd0>4cm\relax
\ifdim\wd0<13cm\relax
\begingroup\centering\begin{lmannot}{#2}\begin{varwidth}{\textwidth}\centering \emph{#1} \end{varwidth} \end{lmannot} \endgroup
\else
\begingroup\centering\begin{mannot} \emph{#1} \end{mannot}\endgroup\fi
\else
\begin{sannot}{#2} \emph{#1} \end{sannot}\fi
}

\usepackage{vmargin}
\setmargins{3cm}          % Left margin 
{1.3cm}                   % Top margin   
{15.6cm}                  % Text width   
{23.42cm}                 % Text height   
{10pt}                    % Headers height
{1cm}                     % Space between headers and text   
{0pt}                     % Footnote height  
{2cm}                     % Space between footnote and text

\begin{document}

\annot{Schnell ab.\\ Kurze Pause. Leontine tritt von der Tür zurück, legt ab. Der Kellner öffnet die Tür von Garilan. Garilan tritt auf, verbeugt sich kurz vor Leontine. Der Neger, mit Garilans riesigem, zettelverklebtem Koffer beladen, folgt Garilan und dem Kellner.}
    
\noindent
KELLNER: Es sind unsere besten Räume, mein Herr -\\
GARILAN, \emph{zu Leontine}: Die Karawane steht übermorgen bereit
\annot{Zum Neger.}{Ab!} \annot{Neger setzt den Koffer ab.}

\noindent       
KELLNER: Zu den Schlafzimmern, zum Bad, mein Herr -\\
GARILAN, \emph{zum Neger}: Wie viel?\\
NEGER, \emph{zeigt >>sechs<<}: Sitta.\\
GARILAN, \emph{bedeutet}: Zu viel!\\
NEGER, \emph{zeigt >>fünf<<}: Chámsa.\\
GARILAN, \emph{bedeutet}: Zu viel!\\\\

\hrule\bigskip\bigskip

\noindent
GARILAN: Sacre nom de Dieu! Porco di diavolo! Allah il Allah! God save the King!\\
LEONTINE: Du wirst dich beschweren, Liebling!

\annot{Sie trägt Koffereinlangen ins Schlafzimmer. \\ Garilan öffnet.}

\noindent
GARILAN: Was wollen Sie denn?


    
\end{document}

相关内容