这个问题是从帖子中找到的这里。我想获取生成此封面的代码这里:
我仍然无法让整页图像tikz
显示出来。以下是根据以下建议修改的代码:约翰·科米洛并进行其他调整:
\documentclass[11pt,letterpaper]{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds, calc, shadows, shadows.blur}
\usepackage{graphicx}
\pgfmathdeclarerandomlist{MyRandomColors}{%
{red}%
{red!25}%
{magenta}%
{magenta!25}%
{olive}%
{olive!25}%
{brown}%
{brown!10}%
{violet}%
{violet!25}%
{gray}%
{purple}%
{yellow}%
{orange}%
{orange!25}%
{cyan}%
{green}%
}%
\newcommand*{\GridSize}{20}
\newcommand*{\ColorCells}{%
\foreach \y in {1,...,\GridSize} {
\foreach \x in {1,...,\GridSize} {
\pgfmathrandomitem{\RandomColor}{MyRandomColors}
\draw [fill=\RandomColor, fill opacity=0.2, draw=none, ultra thick]
(\x-1,\y-1) rectangle (\x,\y);
}%
}%
}%
\listfiles
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
\coordinate (Origin) at (0,0);
\begin{scope}[scale=0.8,ultra thick,olive!45]
\ColorCells
\draw (0, 0) grid (\GridSize, \GridSize);
\coordinate (input);
\end{scope}
\node[rotate=90,above right] at ($(current bounding box.south east)+(-1,1)$)
{\textcolor[rgb]{0.01,0.50,1.00}{\fontsize{50}{120}\selectfont{\textbf{the name of the course}}}};
\node[above right] at ($(current bounding box.south west)+(1,1)$)
{\fontsize{50}{120}\selectfont{name of authorities}};
\end{tikzpicture}
\end{document}
答案1
我对你的代码做了一些修改
- 它与
current page
引用一起工作。 ColorCells
(1cm x 1cm) x scale
已被修改为接受两个参数:xgridsize 和 ygridsize,它们是要绘制的水平和垂直单元格的数量。- 文本节点是参照
current page
而不是 来放置的current size box
。 - 替换
\textcolor...\fontsize...\selectfont
为node font
和text
选项来选择字体就像 TiKZ。
完整代码如下:
\documentclass[11pt,letterpaper]{article}
\usepackage{libertine}
\usepackage{tikz}
\usetikzlibrary{backgrounds, calc, shadows, shadows.blur}
\usepackage{graphicx}
\pgfmathdeclarerandomlist{MyRandomColors}{%
{red}%
{red!25}%
{magenta}%
{magenta!25}%
{olive}%
{olive!25}%
{brown}%
{brown!10}%
{violet}%
{violet!25}%
{gray}%
{purple}%
{yellow}%
{orange}%
{orange!25}%
{cyan}%
{green}%
}%
\definecolor{titlecolor}{rgb}{0.01,0.50,1.00}
\newcommand*{\GridSize}{20}
%#2-Gridsizex
%#3-Gridsizey
\newcommand*{\ColorCells}[2]{%
\foreach \y in {1,...,#1} {
\foreach \x in {1,...,#2} {
\pgfmathrandomitem{\RandomColor}{MyRandomColors}
\draw [draw=olive!45,fill=\RandomColor, fill opacity=0.2, ultra thick]
([shift={(\x-1,\y-1)}]current page.south west) rectangle ++(1cm,1cm);
}%
}%
}%
\listfiles
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\begin{scope}[scale=0.8,ultra thick,olive!45]
\ColorCells{35}{27}
\coordinate (input);
\end{scope}
\node[rotate=90, above right,
node font=\fontsize{70}{90}\selectfont\bfseries\sffamily,
text=titlecolor] at ($(current page.south east)+(-1,1)$)
{the name of the course};
\node[above right,
node font=\fontsize{40}{90}\selectfont\bfseries\sffamily,
text=titlecolor!20!black] at ($(current page.south west)+(1,1)$)
{name of authorities};
\end{tikzpicture}
\end{document}
结果如下: