Tikz 图片左侧不需要的空白

Tikz 图片左侧不需要的空白

我正在尝试重新创建这个: 我正在尝试重新制作的横幅

这是我目前所拥有的: 我的休闲

从这张图片中你可能无法看出来,但图片左侧有一些空白,我不知道为什么。我想知道是否有人可以解释一下它是从哪里来的!

代码:

\documentclass[12pt]{standalone}

\usepackage[T1]{fontenc}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\colorlet{Random0}{Yellow!50!DarkKhaki}
\colorlet{Random1}{Yellow!50!DarkKhaki}
\usepackage{kpfonts}
\usetikzlibrary{fadings}
\usepackage[ttdefault=true]{AnonymousPro}
%\usepackage{courier}
\usepackage{contour}

\begin{document}
    \contourlength{0.1pt} %how thick each copy is

\begin{tikzpicture}[yshift=-3cm]
\path[fill=%DodgerBlue,
CornflowerBlue,
%DeepSkyBlue!70!MidnightBlue,
path fading=east] (0,0) rectangle(\paperwidth,3cm);
\foreach \x in {35,...,70}{
    \foreach \y in {0,...,7} 
    \pgfmathsetmacro\Random{random(0,1)}
    \node[draw=none,color=Random\Random,anchor=south west,font=\ttfamily\bfseries] 
    at (\x*.3cm,\y*.33cm) 
    {\Random};};
\node[anchor=south west,font=\LARGE\bfseries,yshift=0.7cm]{%\contour{Black}
    {\textcolor{OliveDrab}{$
\text{z-value}=\frac{1.752\times .123}{\sqrt{.123^2\times .267^2+1.752^2\times .011^2}}=\frac{.215496}{\sqrt{.015\times .082+3.07\times .0001}}
$}}};
\end{tikzpicture}

\end{document}

答案1

白色空间来自\begin{document}和之间的内容\begin{tikzpicture}。您可以直接移到\contourlength{0.1pt}之前\begin{document}

\documentclass[12pt]{standalone}

\usepackage[T1]{fontenc}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\colorlet{Random0}{Yellow!50!DarkKhaki}
\colorlet{Random1}{Yellow!50!DarkKhaki}
\usepackage{kpfonts}
\usetikzlibrary{fadings}
\usepackage[ttdefault=true]{AnonymousPro}
\usepackage{contour}
\contourlength{0.1pt} %how thick each copy is
\begin{document}
\begin{tikzpicture}
\path[fill=%DodgerBlue,
CornflowerBlue,
%DeepSkyBlue!70!MidnightBlue,
path fading=east] (0,0) rectangle(\paperwidth,3cm);
\foreach \x in {35,...,70}{
    \foreach \y in {0,...,7} 
    \pgfmathsetmacro\Random{random(0,1)}
    \node[draw=none,color=Random\Random,anchor=south west,font=\ttfamily\bfseries] 
    at (\x*.3cm,\y*.33cm) 
    {\Random};};
\node[anchor=south west,font=\LARGE\bfseries,yshift=0.7cm]{%\contour{Black}
    {\textcolor{OliveDrab}{$
\text{z-value}=\frac{1.752\times .123}{\sqrt{.123^2\times .267^2+1.752^2\times .011^2}}=\frac{.215496}{\sqrt{.015\times .082+3.07\times .0001}}
$}}};
\end{tikzpicture}
\end{document}

或者您可以使用standalone进行裁剪。为此,请添加tikz到 standalone 的选项中,这将加载tikz并使 成为tikzpicture独立环境。为了避免 的选项冲突xcolor,您需要\PassOptionsToPackage{svgnames}{xcolor}

\PassOptionsToPackage{svgnames}{xcolor}
\documentclass[12pt,tikz]{standalone}
\usepackage[T1]{fontenc}
\colorlet{Random0}{Yellow!50!DarkKhaki}
\colorlet{Random1}{Yellow!50!DarkKhaki}
\usepackage{kpfonts}
\usetikzlibrary{fadings}
\usepackage[ttdefault=true]{AnonymousPro}
%\usepackage{courier}
\usepackage{contour}

\begin{document}
    \contourlength{0.1pt} %how thick each copy is

\begin{tikzpicture}
\path[fill=%DodgerBlue,
CornflowerBlue,
%DeepSkyBlue!70!MidnightBlue,
path fading=east] (0,0) rectangle(\paperwidth,3cm);
\foreach \x in {35,...,70}{
    \foreach \y in {0,...,7} 
    \pgfmathsetmacro\Random{random(0,1)}
    \node[draw=none,color=Random\Random,anchor=south west,font=\ttfamily\bfseries] 
    at (\x*.3cm,\y*.33cm) 
    {\Random};};
\node[anchor=south west,font=\LARGE\bfseries,yshift=0.7cm]{%\contour{Black}
    {\textcolor{OliveDrab}{$
\text{z-value}=\frac{1.752\times .123}{\sqrt{.123^2\times .267^2+1.752^2\times .011^2}}=\frac{.215496}{\sqrt{.015\times .082+3.07\times .0001}}
$}}};
\end{tikzpicture}

\end{document}

相关内容