tikz 准确性存在问题,即使使用 fpu

tikz 准确性存在问题,即使使用 fpu

我正在尝试绘制 Villard 图(例如,http://retinart.net/graphic-design/secret-law-of-page-harmony/),这是格式化打印页面的经典方法。到目前为止,我有这个:

\documentclass[tikz,border=2mm]{standalone}
\usepackage{fp}
\usetikzlibrary{calc,fpu}

%\pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}

\newlength\textwd
\newlength\textht
\newlength\innerM
\newlength\botM

\newcommand{\villard}[5]{% {page width}{page height}{text block % of page area}{Verso text (not used)} {Recto text}
    \begin{tikzpicture}
        %\tikzset{fixed point arithmetic}%
        \coordinate (c1) at (0,0);
        \coordinate (c2) at (#1,0);
        \coordinate (c3) at (#1,#2);
        \coordinate (c4) at (0,#2);
        \coordinate (c5) at ($(c1)!0.5!(c4)$);
        \draw (c1) -- (c2) -- (c3) -- (c4) -- cycle;
        \draw (c2) -- (c4);
        \draw (c5) -- (c3);
        \pgfmathsetmacro{\areapcsqr}{sqrt(#3)}%
        \pgfmathsetlength{\textwd}{#1*\areapcsqr}%
        \pgfmathsetlength{\textht}{#2*\areapcsqr}%
        \pgfmathsetlength{\innerM}{(#1-\textwd)*.333333333333}%
        \pgfmathsetlength{\botM}{2.0*(#2-\textht)*.333333333333}%
        \coordinate (C) at (\innerM+\textwd*0.5,\botM+\textht*0.5);
        \node[draw,text width=\textwd, minimum height=\textht,align=center] at (C) {#5};
        \draw[red] ($(c4)!0.11!(c2)$) circle (18pt);
        \draw[red] ($(c4)!0.78!(c2)$) circle (18pt);
        \draw[red] ($(c3)!0.225!(c5)$) circle (18pt);
    \end{tikzpicture}
}

\begin{document}

\villard{4.25in}{8.5in}{.45}{}{Right hand text.}

\end{document}

由此产生了如下结果:

Villard 图

接近了,但对我来说还不够接近。如你所见,我尝试了各种方法,但似乎都无济于事。我使用的是最近更新的 MacTeX2015。

我错过了什么?

答案1

您需要从节点中删除内部 sep:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc}

\newlength\textwd
\newlength\textht
\newlength\innerM
\newlength\botM

\newcommand{\villard}[5]{%
    \begin{tikzpicture}
        %\tikzset{fixed point arithmetic}%
    \coordinate (c1) at (0,0);
    \coordinate (c2) at (#1,0);
    \coordinate (c3) at (#1,#2);
    \coordinate (c4) at (0,#2);
    \coordinate (c5) at ($(c1)!0.5!(c4)$);
    \draw (c1) -- (c2) -- (c3) -- (c4) -- cycle;
    \draw (c2) -- (c4);
    \draw (c5) -- (c3);
    \pgfmathsetmacro{\areapcsqr}{sqrt(#3)}%
    \pgfmathsetlength{\textwd}{#1*\areapcsqr}%
    \pgfmathsetlength{\textht}{#2*\areapcsqr}%
    \pgfmathsetlength{\innerM}{(#1-\textwd)*.333333333333}%
    \pgfmathsetlength{\botM}{2.0*(#2-\textht)*.333333333333}%
    \coordinate (C) at (\innerM+\textwd*0.5,\botM+\textht*0.5);
    \node[draw,text width=\textwd, minimum height=\textht,align=center,inner sep=0pt] at (C) {#5};
    \draw[red] ($(c4)!0.11!(c2)$) circle (18pt);
    \draw[red] ($(c4)!0.78!(c2)$) circle (18pt);
    \draw[red] ($(c3)!0.225!(c5)$) circle (18pt);
    \end{tikzpicture}
}

\begin{document}

\villard{4.25in}{8.5in}{.35}{}{Right hand text.}

\end{document}

请注意,我删除了fpfpu引用,因为它们未被使用。请参阅问题的评论以了解红色圆圈的说明。

Villard 结果

相关内容