右侧多余的空间

右侧多余的空间

考虑以下代码:

% DOCUMENT TYPE
\documentclass[12pt,a4paper]{article}

% PACKAGES
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{color}
\usepackage{tikz}
\usepackage[normalem]{ulem}
\usepackage[top=1.25in, bottom=1.25in, left=1.25in, right=1.25in]{geometry}
\usepackage{calc}
\usetikzlibrary{calc}
\usetikzlibrary{fadings}

% DOCUMENT BEGINNING
\begin{document}
\section{First section}
\lipsum
\centerline{%
\begin{tikzpicture} 
\clip[preaction={blue,fill}] (0,0) rectangle (\paperwidth,-2cm); 
\fill[white,path fading=circle with fuzzy edge 10 percent] ( -0.92cm, -5cm) ellipse (8.9cm and 6.7cm); 
\end{tikzpicture}
}
\lipsum
\end{document}

其结果如下: 数字

以下是两个问题:

  • 如何正确对齐矩形与页面(右侧有一个小空间,我不明白为什么)
  • 如何获得 5% 的模糊边缘?(因为目前如果我写“模糊边缘为 5% 的圆圈”,tex 不会编译)

答案1

右侧多余的空间

第一个问题只是行尾的一个不需要的空格:

\centerline{%
  \begin{tikzpicture}...\end{tikzpicture}
}

然后将tikzpicture宽度\paperwidth加上后面的空间 \end{tikzpicture}居中,留下一半的空间在纸张的右侧。解决方案:

\centerline{%
  \begin{tikzpicture}...\end{tikzpicture}%
}

circle with fuzzy edge 5 percent

该数字不是变量,只有固定的百分比:

  • circle with fuzzy edge 10 percent
  • circle with fuzzy edge 15 percent
  • circle with fuzzy edge 20 percent

它们在文件中定义pgflibraryfadings.code.tex。类似地,也5 percent可以定义缺失的内容:

\pgfdeclareradialshading{tikz@lib@fade@circle@5}{\pgfpointorigin}{%
  color(0pt)=(pgftransparent!0); color(23.75bp)=(pgftransparent!0);%
  color(25bp)=(pgftransparent!100); color(50bp)=(pgftransparent!100)%
}
\pgfdeclarefading{circle with fuzzy edge 5 percent}{%
  \pgfuseshading{tikz@lib@fade@circle@5}%
}

唯一需要重新计算 5% 的值是23.75bp。它比以下 的小 5% 25bp

完整示例:

\documentclass[12pt,a4paper]{article}

\usepackage{lipsum}
\usepackage[top=1.25in, bottom=1.25in, left=1.25in, right=1.25in]{geometry}
\usepackage{tikz}
\usetikzlibrary{fadings}

\makeatletter
\pgfdeclareradialshading{tikz@lib@fade@circle@5}{\pgfpointorigin}{%
  color(0pt)=(pgftransparent!0); color(23.75bp)=(pgftransparent!0);%
  color(25bp)=(pgftransparent!100); color(50bp)=(pgftransparent!100)%
}
\pgfdeclarefading{circle with fuzzy edge 5 percent}{%
  \pgfuseshading{tikz@lib@fade@circle@5}%
}
\makeatother

\begin{document}
\lipsum[7]
\centerline{%
  \begin{tikzpicture}
    \clip[preaction={blue,fill}] (0,0) rectangle (\paperwidth,-2cm);
    \fill[white,path fading=circle with fuzzy edge 5 percent] ( -0.92cm, -5cm)
    ellipse (8.9cm and 6.7cm);
  \end{tikzpicture}%
}
\lipsum[1]
\end{document}

结果

相关内容