我很高兴知道我们有一个可以回答/提示问题的社区。
在这里我想问你一个问题。我正在为我们的计算机科学部门设计一本小册子。我想把大约 20-25 个计算机科学流行语(我随身带着)随机地散布在 A4 页面上的不同方向。在此基础上,我想有一个渐变颜色/图像。有人试过这个吗?
答案1
您可以为此使用 TikZ。
通过overlay, remember picture
向 提供选项tikzpicture
,您可以访问current page
节点来定位相对于整个页面的对象。
可以将单词提供给foreach
循环,以逗号分隔。列表中的当前位置可用为\count
。为了在页面上实现相对均匀的分布,我使用了依赖于的xshift
和,这将单词定位在网格中。可以使用另一组和引入随机性,使用。随机种子通常根据系统时间(以分钟为单位)设置,但为了获得可重现的结果,您应该在图片开始时使用。yshift
mod(\count,<value>)
xshift
yshift
rand*<length>
\pgfmathsetseed{<integer>}
以下是一个例子:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[overlay,remember picture,shift=(current page.center)]
\pgfmathsetseed{3}
\fill [yellow!20] (current page.south west) rectangle (current page.north east);
\foreach [count=\count] \word in {Environmental Management,Corporate Social Responsibility,Greening,Industrial Ecology,Stakeholder Management,Life-Cycle Management,Pollution Prevention,Sustainable Development,Design for Environment,Green Design,Urban Reinvestment,Brownfield Redevelopment,ISO 14001,Waste Reduction,Closed Loops,Resource Productivity,Sustainable Technology,Radical Transactiveness,Systems Thinking,Corporate Governance} {
\node [
xshift={(mod(\count,3)-1)*(\paperwidth/4)},
yshift={(mod(\count,7)-3)*(\paperwidth/6)},
xshift=rand*4cm,
yshift=rand*2cm,
rotate=rand*35,
opacity=rnd*0.5+0.125,
font=\bfseries\sffamily\large] {\word};
}
\node at (current page.north) [yshift=-8cm,scale=6,font=\sffamily\bfseries,text=orange] {BUZZWORDS!};
\node at (current page.center) [minimum width=7cm, minimum height=5cm,shade,top color=cyan!50!yellow,bottom color=green!50!red] {};
\end{tikzpicture}
\end{document}
答案2
虽然对于生产我会建议使用 Jake 的答案,但阅读问题时我想知道是否可以在“普通” LaTeX 中产生类似的效果。
对于渐变填充,最好使用专门的包。但是,使用以下代码很容易产生散乱的文字:
\documentclass{article}
\usepackage{graphicx} % to rotate
\usepackage{picture} % allow units in picture environment
\usepackage{eso-pic} % allows to set up background
\usepackage[first=1,last=1000]{lcg} % pseudorandom number generator
\usepackage{calc} % to easily recalculate random integer to position
\begin{document}
\def\wordlist{Environmental Management,Corporate Social Responsibility,Greening,Industrial Ecology,Stakeholder Management,Life-Cycle Management,Pollution Prevention,Sustainable Development,Design for Environment,Green Design,Urban Reinvestment,Brownfield Redevelopment,ISO 14001,Waste Reduction,Closed Loops,Resource Productivity,Sustainable Technology,Radical Transactiveness,Systems Thinking,Corporate Governance}
\makeatletter % We need \@for construction
\newlength{\randx} \newlength{\randy} % Coordinates of the next word should be saved as random generator produces one number
\AddToShipoutPictureBG*{
\@for\TempVar:=\wordlist\do{%
\rand \setlength{\randx}{\paperwidth*\ratio{\value{rand}mm}{1000mm}} % Set random x position
\rand \setlength{\randy}{\paperheight*\ratio{\value{rand}mm}{1000mm}} % Set random y position
\rand % Generate new random to use as angle
\put(\randx,\randy){\makebox(0,0)[c]{\rotatebox{\value{rand}}{\TempVar}}}% Show next word
}
}
\hrule \vfill {\hfill \Huge{Title} \hfill} \vfill \hrule
\end{document}
在某些情况下它可能会更好:它需要一次乳胶运行(TikZ 需要两次运行才能正确地将图形放置在页面上)并且速度明显更快。