我正在尝试用 LaTeX 创建动画 GIF 信息图。为此,我想将文本框排列成三列布局,行框采用各种颜色,并用波浪线(理想情况下是正弦波)隔开。我有一个关于如何使用 绘制一条分隔线的想法tikz
,但是每个框的背景顶部都必须有匹配的接缝,而且似乎需要\foreach
在\fill
命令中使用 ,而这在语法上似乎是不可能的。有什么tikz
合适的工具吗?我不想用几个相邻的填充形状来绘制它,因为在某些 PDF 查看器中查看时可能会导致闪烁(我也想创建它的 PDF 版本)。大约有 12 个这样的框,颜色和高度各异,所以如果可以自动化的话会很方便。
\documentclass[11pt]{article}
\usepackage{pstricks-add}
\usepackage{pgffor}
\usepackage{lipsum}
\usepackage{calc}
\usepackage{multicol}
\usepackage{framed}
\usepackage{color}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{graphicx}
\usepackage[default,regular]{raleway}
\usepackage[absolute]{textpos}
\usepackage{etoolbox}
\usepackage[utf8]{inputenc}
\usepackage[paperwidth=29.7cm,paperheight=50cm,margin=0cm]{geometry}
\setlength{\parindent}{0cm}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}
\setlength{\lineskiplimit}{2pt}
\setlength{\lineskip}{2pt}
\pagecolor{white}
\definecolor{mygrey}{rgb}{0.6,0.6,0.6}
\definecolor{myurl}{HTML}{5687D1}
\definecolor{myboxbluel}{HTML}{DFF0FD}
\definecolor{myboxblued}{HTML}{6DBAEC}
\newsavebox{\MyMinBackBox}
\newenvironment{myminipage}[0]{%
\begin{lrbox}{\MyMinBackBox}%
\begin{minipage}{29.7cm}%
}{%
\end{minipage}\end{lrbox}%
\begin{tikzpicture}[x=1cm,y=1cm]%
\fill[fill=myboxbluel] (0,-\dimexpr\ht\MyMinBackBox\relax) -- (29.7,-\dimexpr\ht\MyMinBackBox\relax) -- (29.7,0) -- (0,0);
\draw[draw=myboxblued,thick] (29.7,0) -- (0,0);
\end{tikzpicture}%
\llap{\usebox{\MyMinBackBox}}%
}
\begin{document}
\foreach \n in {0,...,4}{%
\thispagestyle{empty}%
\begin{textblock}{10.5}(0.65,0.65)%
Box top left
\end{textblock}%
\begin{textblock}{17.1}(11.8,1.1)%
Box top right
\end{textblock}%
\null%
\vspace{2.4cm}%
\begin{myminipage}%
\begin{multicols}{3}
\lipsum[1]
\columnbreak
\lipsum[2]
\columnbreak
\lipsum[3]
\end{multicols}
\end{myminipage}%
\newpage
}
\end{document}
这大致是上述代码产生的输出。出于某种原因,背景的高度只有应有大小的一半。我也很难为三列容器添加一些填充minipage
,但这可能值得单独提出一个问题。
答案1
在 TikZ 中完成整个操作:
代码
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,fit,backgrounds,decorations.pathmorphing}
\usepackage{lipsum}
\usepackage[default,regular]{raleway}
\usepackage[paperwidth=32cm,paperheight=50cm,margin=1cm]{geometry}
\setlength{\parindent}{0cm}
\pagecolor{white}
\definecolor{mygrey}{rgb}{0.6,0.6,0.6}
\definecolor{myurl}{HTML}{5687D1}
\definecolor{myboxbluel}{HTML}{DFF0FD}
\definecolor{myboxblued}{HTML}{6DBAEC}
\newsavebox{\MyMinBackBox}
\newcommand\myminipage[2][]{\node[text width=9.3cm,inner sep=0pt,#1] {#2};}
\tikzset{
myborder/.style={
decorate,decoration={snake},
}
}
\begin{document}
\vspace*{6cm}
\begin{tikzpicture}[remember picture,overlay]
\myminipage[name=box11,anchor=west]{\lipsum[1]}
\myminipage[name=box12,right=of box11.north east,anchor=north west]{\lipsum[2]}
\myminipage[name=box13,right=of box12.north east ,anchor=north west]{\lipsum[3]}
\begin{pgfonlayer}{background}
\node[
inner xsep=0pt,
inner ysep=25pt,
fit={(box11.north west) (box11.south west) (box13.south east)}
] (bgupper) {};
\begin{scope}
\clip[myborder]
([shift={(-2cm,-10pt)}]bgupper.north west) --
([shift={(2cm,-10pt)}]bgupper.north east) --
([shift={(2cm,-2cm)}]bgupper.south east) --
([shift={(-2cm,-2cm)}]bgupper.south west) -- cycle
;
\fill[blue!20]
([xshift=-10pt]bgupper.north west) rectangle ([xshift=10pt]bgupper.south east);
\end{scope}
\end{pgfonlayer}
\myminipage[name=box21,below=5pt of bgupper.south west,anchor=north west]{\lipsum[4]}
\myminipage[name=box22,right=of box21.north east,anchor=north west]{\lipsum[2]}
\myminipage[name=box23,right=of box22.north east ,anchor=north west]{\lipsum[1]}
\begin{pgfonlayer}{background}
\node[
inner xsep=0pt,
inner ysep=25pt,
fit={(box21.north west) (box21.south west) (box23.south east)}
] (bgmiddle) {};
\begin{scope}
\clip[myborder]
([shift={(-2cm,-10pt)}]bgmiddle.north west) --
([shift={(2cm,-10pt)}]bgmiddle.north east) --
([shift={(2cm,-2cm)}]bgmiddle.south east) --
([shift={(-2cm,-2cm)}]bgmiddle.south west) -- cycle
;
\fill[yellow!20]
([xshift=-10pt]bgmiddle.north west) rectangle ([xshift=10pt]bgmiddle.south east);
\end{scope}
\end{pgfonlayer}
\myminipage[name=box31,below=15pt of bgmiddle.south west,anchor=north west]{\lipsum[4]}
\myminipage[name=box32,right=of box31.north east,anchor=north west]{\lipsum[2]}
\myminipage[name=box33,right=of box32.north east ,anchor=north west]{\lipsum[1]}
\begin{pgfonlayer}{background}
\node[
inner xsep=0pt,
inner ysep=25pt,
fit={(box31.north west) (box31.south west) (box33.south east)}
] (bglower) {};
\begin{scope}
\clip[myborder]
([shift={(-2cm,-10pt)}]bglower.north west) --
([shift={(2cm,-10pt)}]bglower.north east) --
([shift={(2cm,15pt)}]bglower.south east) --
([shift={(-2cm,15pt)}]bglower.south west) -- cycle
;
\fill[red!20]
([xshift=-10pt]bglower.north west) rectangle ([xshift=10pt]bglower.south east);
\end{scope}
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
填充是在background
图层中完成的;波浪边框是使用剪辑和snake
装饰制作的。