我想在一张图片上以随机大小和随机旋转角度放置几个问号,我做不到,如有任何建议我将不胜感激。
\documentclass[tikz,border=5pt]{article}
\usepackage{graphicx}
\usepackage{picture}
\usepackage{eso-pic}
\usepackage[first=1,last=1000]{lcg}
\usepackage{calc}
\begin{document}
\pagestyle{empty}
\centering
\includegraphics{librarys}
\def\wordlist{\textquestiondown,\textquestiondown,\textquestiondown,\textquestiondown,\textquestiondown}
\makeatletter
\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
}
}
\end{document}
答案1
以下是使用 tikz 的示例。请注意,由于记住图片缓存内容,您可能需要删除辅助文件以强制其重新定位。
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}
\fill[blue] (0,0) circle (5);
\end{tikzpicture}
\begin{tikzpicture}[remember picture,overlay]
% I'll just use letters
\foreach \letter in {A,B,C,D,E}{
\pgfmathsetmacro\randA{random()}
\coordinate (A) at ($(current page.north west)!\randA!(current page.north east)$);
\pgfmathsetmacro\randB{random()}
\coordinate (B) at ($(current page.north west)!\randB!(current page.south west)$);
\coordinate (C) at ($(A |- B)$);
\typeout{A: \randA; B: \randB}
\node at (C) {\Huge \letter};
}
\end{tikzpicture}
\end{document}