LaTeX - 定义自定义“wrapfig”环境

发布于 2024-09-09 07:46:57 字数 952 浏览 0 评论 0原文

我正在用 LaTeX 排版一本书。文本设计包括拉引号,它应该看起来像这样:

Chicken chicken chicken chicken  -------------
chicken chicken chicken chicken     CHICKEN
chicken chicken chicken chicken     CHICKEN
chicken chicken chicken chicken  -------------
chicken chicken chicken chicken chicken chicken

所以,wrapfig.sty看起来它有我需要的基本机制,我只需要定义一个执行水平操作的环境规则、居中和更大的类型。问题是 wrapfigure 似乎不想嵌套在环境定义中。如果我在文本正文中包含此内容,则它可以工作

\begin{wrapfigure}{o}{2in}
\large chicken chicken
\end{wrapfigure}

,但如果我在序言中执行此操作

\newenvironment{pullquote}
  {\begin{wrapfigure}{o}{2in}\large}
  {\end{wrapfigure}}

,然后我

\begin{pullquote}
chicken chicken
\end{pullquote}

收到此错误消息:

Package wrapfig Warning: Collision between wrapping environments ...

引文在我想要的下面的几个段落中排版(在 的大致位置)接下来 重要引述,看起来像,或者在文档的末尾)并且正文不会围绕重要引述。什么给?我该如何进行这项工作?

I'm typesetting a book with LaTeX. The text design includes pull quotes, which are supposed to look something like this:

Chicken chicken chicken chicken  -------------
chicken chicken chicken chicken     CHICKEN
chicken chicken chicken chicken     CHICKEN
chicken chicken chicken chicken  -------------
chicken chicken chicken chicken chicken chicken

So, wrapfig.sty seems like it has the basic mechanism I need, and I just need to define an environment that does the horizontal rules, centering, and larger type. The problem is that wrapfigure doesn't seem to want to be nested in an environment definition. If I have this in my text body it works

\begin{wrapfigure}{o}{2in}
\large chicken chicken
\end{wrapfigure}

but if I do this in the prologue

\newenvironment{pullquote}
  {\begin{wrapfigure}{o}{2in}\large}
  {\end{wrapfigure}}

and then I have

\begin{pullquote}
chicken chicken
\end{pullquote}

I get this error message:

Package wrapfig Warning: Collision between wrapping environments ...

the pull quote is typeset several paragraphs below where I want it (at the approximate location of the next pull quote, it looks like, or else at the end of the document) and the body text doesn't get wrapped around the pull quote. What gives? How do I make this work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贱人配狗天长地久 2024-09-16 07:46:57

我对它没有完全理解,但我怀疑这是因为wrapfigure本身就是图形浮动环境的包装器。

我想我在这里找到了解决方案/解决方法:
http://texblog.net/latex-archive/plaintex/expandafter/

我认为这段代码得到了你想要的:

\documentclass{article}
\usepackage{wrapfig}
\raggedright
\expandafter\def\expandafter\wrapfigure\expandafter{\wrapfigure{o}{2in}\large\raggedright}

\begin{document}

chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
\begin{wrapfigure}
CHICKEN CHICKEN
CHICKEN CHICKEN
\end{wrapfigure}
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken

\end{document}

上面使用的代码重新定义了“wrapfigure”以具有不同的用途,这可能不是你想要的。您可以为 begin{env} 和 end{env} 创建新命令,使 'wrapfigure' 本身保持不变,如下所示:

\documentclass{article}
\usepackage{wrapfig}
\raggedright

\newcommand{\myfigstart}{\begin{wrapfigure}{o}{2in}\large\raggedright}
\newcommand{\myfigend}{\end{wrapfigure}}

\begin{document}

chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
\myfigstart
CHICKEN CHICKEN CHICKEN CHICKEN
\myfigend
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken

\end{document}

I don't have full understanding of it, but I suspect it's because wrapfigure is itself a wrapper around figure float environment.

I think I found a solution/workaround here:
http://texblog.net/latex-archive/plaintex/expandafter/

I think this code gets what you want:

\documentclass{article}
\usepackage{wrapfig}
\raggedright
\expandafter\def\expandafter\wrapfigure\expandafter{\wrapfigure{o}{2in}\large\raggedright}

\begin{document}

chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
\begin{wrapfigure}
CHICKEN CHICKEN
CHICKEN CHICKEN
\end{wrapfigure}
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken

\end{document}

The code as used above redefines 'wrapfigure' to have different use, which may not be what you want. You can create new commands for the begin{env} and end{env} which leave 'wrapfigure' itself unaltered, like this:

\documentclass{article}
\usepackage{wrapfig}
\raggedright

\newcommand{\myfigstart}{\begin{wrapfigure}{o}{2in}\large\raggedright}
\newcommand{\myfigend}{\end{wrapfigure}}

\begin{document}

chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
\myfigstart
CHICKEN CHICKEN CHICKEN CHICKEN
\myfigend
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken

\end{document}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文