我如何参数化两个 tikz 圆以适应 tufte marginpar?

我如何参数化两个 tikz 圆以适应 tufte marginpar?

我如何参数化圆以适应簇状边缘?我希望能够改变圆的正交位置(可能比例从 0 到 1)并自动调整\diameter以适应\marginparwidth

\documentclass[nofonts]{tufte-handout}

\usepackage{showframe}

\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}

\newcommand{\panning}{1}

\newlength{\diameter}
\setlength{\diameter}{.34\marginparwidth}

\begin{document}
    \begin{marginfigure}
            \begin{tikzpicture}
                \begin{scope}[fill opacity=0.5]
                    \draw (90:\panning) circle (\diameter);
                    \draw (210:\panning) circle (\diameter);
                    \draw (330:\panning) circle (\diameter);
                \end{scope}
            \end{tikzpicture}
        \caption{This is a margin figure.}
    \end{marginfigure}
\end{document}

答案1

简单的计算表明半径(你称之为直径)必须是1/2(\marginparwidth-\sqrt{3}\padding),所以

\documentclass[nofonts]{tufte-handout}
\usepackage{showframe}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}

\newcommand\panning{0.5}
\newlength\diameter
\pgfmathsetlength{\diameter}{0.5*\marginparwidth-0.5*sqrt(3)*\panning cm}    

\begin{document}
    \begin{marginfigure}\centering
            \begin{tikzpicture}
                \begin{scope}[fill opacity=0.5]
                    \draw (90:\panning) circle (\diameter);
                    \draw (210:\panning) circle (\diameter);
                    \draw (330:\panning) circle (\diameter);
                \end{scope}
            \end{tikzpicture}
        \caption{This is a margin figure.}
    \end{marginfigure}
\end{document}

结果:

在此处输入图片描述

相关内容