将文字环绕在符号周围

将文字环绕在符号周围

如何将文本环绕在符号周围?这是我目前的代码:

\documentclass{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{fourier}
\usepackage{blindtext}

\newcommand{\mybox}[2][\danger]{%
    \colorbox{lime}{\parbox{\textwidth}{%
        {\Huge#1}{#2}%
    }}%
}
\begin{document}
\mybox{\blindtext}
\end{document}

答案1

您可以使用lettrine包来实现这一点,它通常用于包含跨多行的大首字母。由于符号的深度较大,因此需要进行一些调整:

\documentclass{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{fourier}
\usepackage{blindtext}
\usepackage{lettrine}

\newcommand{\mybox}[2][\danger]{%
    \colorbox{lime}{\parbox{\textwidth}{%
        \lettrine[lraise=.2,findent=1pt,nindent=0pt]{#1}{}{#2} }%
    }%
}
\begin{document}

\mybox{\blindtext}
\end{document}

在此处输入图片描述

答案2

总体来说,我觉得在 LaTeX 中做到这一点比较困难。shapepar包,可以在文本上挖一个洞,并在洞里放一些东西。但是要定制洞的形状以适应特定的符号并不容易。

预定义圆孔的示例:

\documentclass{article}
\usepackage{shapepar}

\begin{document}

\cutout{r}(-4em,5\baselineskip)\shapepar{\circleshape}
cut cut cut cut cut cut cut cut cut cut cut cut cut cut cut cut
cut cut cut cut cut cut cut cut cut cut cut cut\par
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text
text text text text text text text text text text text text text

\end{document}

在 ConTeXt 中,借助 MetaFun,这类工作更容易完成。您可以参考:

http://mirror.contextgarden.net/general/manuals/metafun-s.pdf


如果你只想要一个矩形孔,你可以使用(旧)picinpar, (较新)picinswrapfig为了这。

对于更简单的情况,lettrine包就足够了。还有\hangindent\hangafter命令来获取特殊形状的段落。

答案3

您可以使用wrapfig为此打包:

 Environments "wrapfigure" and "wraptable" place a figure or table
 at the side of the page and wrap text around it.

 \begin{wrapfigure}[12]{r}[34pt]{5cm} <figure> \end{wrapfigure}
                    --  -  ----  ---
 [number of narrow lines] {placement} [overhang] {width of figure}%

...

Environments similar to "wrapfigure" and "wraptable" may be easily added,
or invoked by "\begin{wrapfloat}{float_name}"

相关内容