我想在一段文字上创建一个大括号。我将在许多段落中使用它。我想让它在左侧和/或右侧标识。这是为了对话风格的作品。
编辑1:我想要的是:
我也想知道方括号的相同情况。我尝试使用一些常规数学模式,但文本超出了页面范围。
编辑2:我现在在这里使用第一个回应:Peter Grill:文本的动态大小括号/圆括号
如何才能使左括号“起作用”,而不会将所有文本压缩到一侧?我得到了 badness 10000。
倾倒:
\documentclass[12pt]{memoir}
\newcommand{\LBracket}[4][0.1\textwidth]{%
\begin{math}%
\left.%
\parbox{#1}{#3}\vphantom{\parbox{#1}{#4}}%
\right#2%
\parbox{#1}{#4}\vphantom{\parbox{#1}{#3}}%
\end{math}
}%
\newcommand{\RBracket}[4][0.9\textwidth]{%
\begin{math}%
\left.%
\parbox{#1}{#3}\vphantom{\parbox{#1}{#4}}%
\right#2%
\parbox{#1}{#4}\vphantom{\parbox{#1}{#3}}%
\end{math}
}%
\begin{document}
\RBracket{)}
{Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsu}
{Words}% Use a round )
\LBracket{\{}
{Words}
{Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsu}% ETC
\end{document}
编辑3:在此期间:我正在使用上面链接中 Werner 的回复。我可以毫不费力地重新调整比例。但更改符号是我无法做到的。
我怎样才能更改括号符号?例如更改为 { 或 [ 等?我在代码中找不到这个控件的位置。
\documentclass[11pt]{memoir}
\usepackage[margin=15mm]{geometry}% http://ctan.org/pkg/geometry
\usepackage{xparse}% http://ctan.org/pkg/xparse
\usepackage{varwidth}% http://ctan.org/pkg/varwidth
\begin{document}
\newsavebox{\leftbox} \newsavebox{\rightbox}%
\NewDocumentCommand{\lrboxbrace}{s O{0.05\linewidth} m O{0.8\linewidth} m}{% \lrboxbrace[<lwidth>]{<ltext>}[<rwidth>]{<rtext>}
\begin{lrbox}{\leftbox}% Left box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#2}#3\end{varwidth}}
{\begin{minipage}{#2}#3\end{minipage}}
\end{lrbox}
\begin{lrbox}{\rightbox}% Right box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#4}#5\end{varwidth}}
{\begin{minipage}{#4}#5\end{minipage}}
\end{lrbox}
\ensuremath{\left.\usebox\leftbox\rule{0pt}{\ht\rightbox}\right\}\usebox\rightbox}
}
\lrboxbrace%
{Word}%
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifend
tincidunt enim, eu tincidunt felis auctor quis. Aenean eget enim urna.
Pellentesque tincidunt adipiscing velit a fermentum. \endgraf
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifend
tincidunt enim, eu tincidunt felis auctor quis. Aenean eget enim urna.
Pellentesque tincidunt adipiscing velit a fermentum.}
\end{document}
编辑4:对于只有一个括号的段落,我正在尝试找到解决方案。当我尝试在括号中“Word”所在的位置留出一个空白时,它会导致错位。这两个段落不再完美地放在彼此的下方。带有 {} 的段落位于第一段的稍左位置。
显然这是由于指定了比例尺寸。但我希望保留它,以便它可以根据任何文档进行调整。但在此期间,我在那里放了一个下划线,但它带来了严重的错误。我该怎么办?
特克斯:
\documentclass[oldfontcommands,12pt]{memoir}
\usepackage[margin=1in, paperwidth=8.5in, paperheight=11in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{xparse}% http://ctan.org/pkg/xparse
\usepackage{varwidth}% http://ctan.org/pkg/varwidth
\usepackage{musixtex}
\usepackage{feyn}
\usepackage{feynmp}
% Bracket commands:
%% Box array setup:
\newsavebox{\leftbox} \newsavebox{\rightbox}%
%%% Box Bracket Command:
\NewDocumentCommand{\boxbrace}{s O{\{} O{\}} O{0.05\linewidth} m O{0.8\linewidth} m}{% \lrboxbrace[<lbrace>][<rbrace>][<lwidth>]{<ltext>}[<rwidth>]{<rtext>}
\begin{lrbox}{\leftbox}% Left box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#4}#5\end{varwidth}}
{\begin{minipage}{#4}#5\end{minipage}}
\end{lrbox}
\begin{lrbox}{\rightbox}% Right box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#6}#7\end{varwidth}}
{\begin{minipage}{#6}#7\end{minipage}}
\end{lrbox}
\ensuremath{\usebox\leftbox\left#2\,\usebox\rightbox\,\right#3}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
Example of full brackets on both sides. By default it fully covers
both sides of the paragraph.
\begin{center}
\boxbrace {abc}%
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
eleifend tincidunt enim, eu tincidunt felis auctor quis. Aenean eget
enim urna. Pellentesque tincidunt adipiscing velit a
fermentum. \endgraf Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed eleifend tincidunt enim, eu tincidunt felis
auctor quis. Aenean eget enim urna. Pellentesque tincidunt
adipiscing velit a fermentum.}
\end{center}
Example of only one bracket: just fill the relevant comment area with
a single full stop.
\begin{center}
\boxbrace [\lbrace][.] {abc}%
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
eleifend tincidunt enim, eu tincidunt felis auctor quis. Aenean eget
enim urna. Pellentesque tincidunt adipiscing velit a
fermentum. \endgraf Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed eleifend tincidunt enim, eu tincidunt felis
auctor quis. Aenean eget enim urna. Pellentesque tincidunt
adipiscing velit a fermentum.}
\end{center}
With a second one to follow
\begin{center}
\boxbrace [.][\rbrace] {_}%
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
eleifend tincidunt enim, eu tincidunt felis auctor quis. Aenean eget
enim urna. Pellentesque tincidunt adipiscing velit a
fermentum. \endgraf Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed eleifend tincidunt enim, eu tincidunt felis
auctor quis. Aenean eget enim urna. Pellentesque tincidunt
adipiscing velit a fermentum.}
\end{center}
Errors turn up here. Otherwise with just a space it's misaligned like
this:
\begin{center}
\boxbrace [.][\rbrace] { }%
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
eleifend tincidunt enim, eu tincidunt felis auctor quis. Aenean eget
enim urna. Pellentesque tincidunt adipiscing velit a
fermentum. \endgraf Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed eleifend tincidunt enim, eu tincidunt felis
auctor quis. Aenean eget enim urna. Pellentesque tincidunt
adipiscing velit a fermentum.}
\end{center}
\end{document}
编辑5:再次 Bach!目前正在尝试双括号:单词 {para}{para} 单词都在一行上。我正在尝试玩弄代码。但我似乎无法让它工作。这是我的尝试。任何建议都非常感谢!
命令:
%% Dual Convo Bracket Command:
\NewDocumentCommand{\dboxbrace}{s O{\{} O{\}} O{0.05\linewidth} m O{0.4\linewidth} m }{% \lrboxbrace[<lbrace>][<rbrace>][<lwidth>]{<ltext>}[<rwidth>]{<rtext>}
\begin{lrbox}{\leftlatbox}% Left Lateral box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#4}#5\end{varwidth}}
{\begin{minipage}{#4}#5\end{minipage}}
\end{lrbox}
\begin{lrbox}{\rightmedbox}% Right Medial box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#6}#7\end{varwidth}}
{\begin{minipage}{#6}#7\end{minipage}}
\begin{lrbox}{\leftmedbox}% Left Medial box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#4}#5\end{varwidth}}
{\begin{minipage}{#4}#5\end{minipage}}
\end{lrbox}
\begin{lrbox}{\rightlatbox}% Right Lateral box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#6}#7\end{varwidth}}
{\begin{minipage}{#6}#7\end{minipage}}
\end{lrbox}
\ensuremath{\usebox\leftlatbox\left#2\usebox\rightmedbox\right#3\left#2\usebox\leftmedbox\right#3\usebox\rightlatbox}
}
尝试使用示例
%% Example of dual Work
\begin{center}
\dboxbrace {word} {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
eleifend tincidunt enim, eu tincidunt felis auctor quis. Aenean eget
enim urna. Pellentesque tincidunt adipiscing velit a
fermentum. \endgraf Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed eleifend tincidunt enim, eu tincidunt felis
auctor quis. Aenean eget enim urna. Pellentesque tincidunt
adipiscing velit a fermentum.} {Lorem ipsum dolor sit amet, sectetur adipiscing elit. Sed
eleifend tincidunt enim, eu tincidunt felis auctor quis. Aenean eget
enim urna. Pellentesque tincidunt adipiscing velit a
fermentum. \endgraf Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed eleifend tincidunt enim, eu tincidunt felis
auctor quis. Aenean eget enim urna. Pellentesque tincidunt
adipiscing velit a fermentum.} {word}
\end{center}
答案1
Werner 代码中的括号隐藏在宏的最后一行,\}
前面是\right
。下面是对他的代码的简单修改,使括号成为可选参数,同时提供右括号并调整了一些间距:
\documentclass[11pt]{memoir}
\usepackage[margin=15mm]{geometry}% http://ctan.org/pkg/geometry
\usepackage{xparse}% http://ctan.org/pkg/xparse
\usepackage{varwidth}% http://ctan.org/pkg/varwidth
\begin{document}
\newsavebox{\leftbox} \newsavebox{\rightbox}%
\NewDocumentCommand{\lrboxbrace}{s O{\{} O{\}} O{0.05\linewidth} m O{0.8\linewidth} m}{% \lrboxbrace[<lbrace>][<rbrace>][<lwidth>]{<ltext>}[<rwidth>]{<rtext>}
\begin{lrbox}{\leftbox}% Left box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#4}#5\end{varwidth}}
{\begin{minipage}{#4}#5\end{minipage}}
\end{lrbox}
\begin{lrbox}{\rightbox}% Right box
\IfBooleanTF{#1}% starred/unstarred
{\begin{varwidth}{#6}#7\end{varwidth}}
{\begin{minipage}{#6}#7\end{minipage}}
\end{lrbox}
\ensuremath{\usebox\leftbox\left#2\,\usebox\rightbox\,\right#3}
}
\begin{center}
\lrboxbrace {Word}%
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
eleifend tincidunt enim, eu tincidunt felis auctor quis. Aenean eget
enim urna. Pellentesque tincidunt adipiscing velit a
fermentum. \endgraf Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed eleifend tincidunt enim, eu tincidunt felis
auctor quis. Aenean eget enim urna. Pellentesque tincidunt
adipiscing velit a fermentum.}
\end{center}
\begin{center}
\lrboxbrace[{[}][{]}] [0.4\textwidth]{Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Sed eleifend tincidunt enim, eu
tincidunt felis auctor quis. Aenean eget enim urna. Pellentesque
tincidunt adipiscing velit a fermentum. }%
[0.4\textwidth]{Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Sed eleifend tincidunt enim, eu tincidunt felis auctor
quis. Aenean eget enim urna. Pellentesque tincidunt adipiscing
velit a fermentum. \endgraf Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed eleifend tincidunt enim, eu tincidunt felis
auctor quis. Aenean eget enim urna. Pellentesque tincidunt
adipiscing velit a fermentum.}
\end{center}
\begin{center}
\lrboxbrace[\langle][\rangle] {Word}%
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
eleifend tincidunt enim, eu tincidunt felis auctor quis. Aenean eget
enim urna. Pellentesque tincidunt adipiscing velit a
fermentum.}
\end{center}
\begin{center}
\lrboxbrace[\Vert][\Vert] {Word}%
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
eleifend tincidunt enim, eu tincidunt felis auctor quis. Aenean eget
enim urna. Pellentesque tincidunt adipiscing velit a
fermentum.}
\end{center}
\end{document}
答案2
我建议使用包的一种方法tcolorbox
。基于 TikZ 层,您可以使用很多选项来操作输出。下面非常简单,并提供了左括号环境的示例。当然,您可以自由添加其他环境。
\documentclass[11pt]{memoir}
\usepackage{showframe}
\usepackage{tikz,lipsum}
\usetikzlibrary{decorations.pathreplacing}
\usepackage[listings,theorems,skins,breakable]{tcolorbox}
\tcbset{skin=enhanced}
\newtcolorbox{lbracebox}[1][Word]{%
colback=green!5,frame hidden,enlarge left by=2cm,width=\linewidth-2cm,%
overlay unbroken = {\draw [line width=2pt,decorate,decoration={brace,amplitude=10pt},]%
(frame.south west)-- (frame.north west)
node [black,midway,left,xshift=-.6cm] {#1};},%
}
\usepackage{lipsum}
\begin{document}
\begin{lbracebox}{Word}
\lipsum[1]
\end{rbracebox}
\begin{lbracebox}[$P_w$]
\lipsum[1]
\end{rbracebox}
\end{document}
答案3
解决方案可以是包schemata
。命令\schema
或\Schema
可以打印开/关括号(或方括号或圆括号)。这些命令可以嵌套以包含测试或制作树状图。
请注意,您还必须附上每个部分无包装 以\schemabox
避免每个部分扩展到整个文本宽度,而不是填充最小(或可选固定)宽度。当需要换行时,可以minipage
在 内包含一个环境来解决\schemabox
。
\documentclass[10pt]{article}
\usepackage{schemata} % the important package
\usepackage{microtype} % better spacing in narrow paragraph
% \mytext macro (simple sample text to avoid typing)
\def\mytext{All work and no play makes Jack a dull boy. }%
% \idea{width} make paragraphs inside braces diagrams of custom width
\newcommand{\idea}[1]{
\schemabox{
\begin{minipage}{#1\textwidth}
\mytext \mytext
\end{minipage}
}
}
% Diagram style: Use () or [] instead of {}
% \BoBraces (default)
% \DoParens
% \DoBrackets
\begin{document}
\section*{Jack Torrance's novel structure}
% Introducing hipothesis (normal paragraphs)
\mytext \mytext \mytext \mytext
\vspace{3ex}
% SHEMATIC ABSTRACT
\Schema[open]{0ex}{2ex}{\schemabox{Jack}}
{\Schema[close]{0ex}{2ex}{\schemabox{all work\\ no play}}
{\schemabox{dull boy}}}
% UNDERSTANDING ELEMENTS FROM THE IDEA
% note that closing parenthesis is smaller (nested) Compare by above.
\vspace{3ex}
\DoParens
\schema[open]{\schemabox{All work and no play \\ makes Jack a dull boy}}{\schema[close]{\schemabox{All work\\ and\\no play}}
{\schemabox{makes Jack a dull boy}}}
\DoBrackets
%
%CONCEPT RELATIONSHIPS FULL EXPLAINED
% now with braces of equal size
\vspace{3ex}
\Schema[open]{0ex}{8ex}{\idea{.25}}{
\Schema[close]{0ex}{8ex}{\idea{.15}}{\idea{.50}}}
% note that close brace is smaller (nested)
% RAMIFICATIONS OF THE MAIN CONCEPT
\vspace{3ex}
\DoBraces % return to default
\schema[open]{\idea{.15}}{
\schema[close]{\idea{.25}}{\idea{.50}}
\schema[close]{\idea{.35}}{\idea{.40}}}
% CONCLUSION (more normal paragraphs)
\vspace{3ex}
\mytext \mytext \mytext \mytext
\end{document}