使用 TikZ 使数学圆圈看起来更自然

使用 TikZ 使数学圆圈看起来更自然

在我的幻灯片中,我喜欢圈出我认为观众应该注意的数量。到目前为止,我一直使用nodetikzpicture用 来设计它,rounded corners使其看起来“柔和”。我想知道,有没有办法让这些圆圈看起来更自然?例如,如果你有一台平板电脑并手工制作了这样一个圆圈,它看起来就像用画笔绘制的圆形图形(因为边缘并不均匀),而且形状略呈椭圆形,而不是像我们使用 那样的完美圆角矩形rounded corners。示例:在此处输入图片描述我真的很喜欢这个外观并且想知道是否有办法实现它。

这是我的 MWE,正在执行我上面描述的简单操作。如果能对我的问题提供任何建议,我将不胜感激。

\documentclass{beamer}

\mode<presentation>
{
  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
  \usecolortheme{rose} % or try albatross, beaver, crane, ...
  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
} 
\usepackage{collcell} %pdflatex.exe hangs without this one
\usepackage[customcolors,beamer]{hf-tikz} %for beautiful inline highlighted math. Thanks Claudio! 

\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}

\newcommand\fiteq[1]{%
  \sbox{\mybox}{$\displaystyle#1$}%
  \ifdim\wd\mybox>.85\textwidth\resizebox{.85\textwidth}{!}{\usebox{\mybox}}%
  \else\usebox{\mybox}\fi%
}
\usepackage[export]{adjustbox} %pdflatex.exe hangs without this one
\usepackage[skins]{tcolorbox}
\tcbuselibrary{theorems}
\usetikzlibrary{tikzmark, calc,decorations.pathmorphing,decorations.pathreplacing, patterns}
\usetikzlibrary{arrows.meta, positioning, quotes}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{matrix,overlay-beamer-styles}
\newtcbtheorem[]{mylemmma}{Lemma}{colframe=green,colback=white, width=\textwidth, left=0pt}{lem}
\tcbset{colframe=green, colback=white}  
\resetcounteronoverlays{tcb@cnt@mylemmma}
\newcommand{\inprod}[2]{\left\langle#1, #2\right\rangle}
\newcommand{\1}{\mathbf{1}}

%% start1
\begin{document}
\begin{frame}[t]
\frametitle{my title}


\pause
\vspace{3mm}
\tikzmarknode{mypx}{f}

    \begin{tikzpicture}[remember picture,overlay, 
    tagPx/.style = {
            rounded corners, 
            draw = blue,
            thick,
            fill= white,
            inner ysep=2pt,
            inner xsep=1pt,
            align = center
            }, 
    tagPxThm/.style = {
            inner ysep=2pt,
            inner xsep=1pt,
            align = center
            },]             
\node [minimum width=0pt, style = tagPx]  (phi) at ([xshift = 2cm, yshift=-1 cm]mypx)  {$\scriptstyle(x+y)^2 = x^2 + y^2 + 2xy$};
\draw [stealth-,out=260,in=170] (mypx) to (phi.west);%%%%%
\end{tikzpicture}
    \vspace{5mm}


\end{frame}
\end{document}

答案1

怎么样rounded rectangle

\documentclass{beamer}

\mode<presentation>
{
  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
  \usecolortheme{rose} % or try albatross, beaver, crane, ...
  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
} 
\usepackage{collcell} %pdflatex.exe hangs without this one
\usepackage[customcolors,beamer]{hf-tikz} %for beautiful inline highlighted math. Thanks Claudio! 

\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}

\newcommand\fiteq[1]{%
  \sbox{\mybox}{$\displaystyle#1$}%
  \ifdim\wd\mybox>.85\textwidth\resizebox{.85\textwidth}{!}{\usebox{\mybox}}%
  \else\usebox{\mybox}\fi%
}
\usepackage[export]{adjustbox} %pdflatex.exe hangs without this one
\usepackage[skins]{tcolorbox}
\tcbuselibrary{theorems}
\usetikzlibrary{tikzmark, calc,decorations.pathmorphing,decorations.pathreplacing, patterns}
\usetikzlibrary{arrows.meta, positioning, quotes}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{matrix,overlay-beamer-styles}
\usetikzlibrary{shapes.misc} 
\newtcbtheorem[]{mylemmma}{Lemma}{colframe=green,colback=white, width=\textwidth, left=0pt}{lem}
\tcbset{colframe=green, colback=white}  
\resetcounteronoverlays{tcb@cnt@mylemmma}
\newcommand{\inprod}[2]{\left\langle#1, #2\right\rangle}
\newcommand{\1}{\mathbf{1}}

%% start1
\begin{document}
\begin{frame}[t]
\frametitle{my title}


\pause
\vspace{3mm}
\tikzmarknode{mypx}{f}

    \begin{tikzpicture}[remember picture,overlay, 
    tagPx/.style = {
            rounded rectangle, 
            draw = blue,
            thick,
            fill= white,
            inner ysep=2pt,
            inner xsep=1pt,
            align = center
            }, 
    tagPxThm/.style = {
            inner ysep=2pt,
            inner xsep=1pt,
            align = center
            },]             
\node [minimum width=0pt, style = tagPx]  (phi) at ([xshift = 2cm, yshift=-1 cm]mypx)  {$\scriptstyle(x+y)^2 = x^2 + y^2 + 2xy$};
\draw [stealth-,out=260,in=170] (mypx) to (phi.west);%%%%%
\end{tikzpicture}
    \vspace{5mm}


\end{frame}
\end{document}

在此处输入图片描述

这是为了尝试制作类似于屏幕截图的东西。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,bending,decorations,decorations.pathreplacing,calc,shapes.misc}
\pgfdeclarearrow{name=ink,
  parameters= {\the\pgfarrowlength},  
  setup code={
   \pgfarrowssettipend{0pt}
   \pgfarrowssetlineend{-\pgfarrowlength}
   \pgfarrowlinewidth=\pgflinewidth
   \pgfarrowssavethe\pgfarrowlength
  },
  drawing code={
   \pgfpathmoveto{\pgfpoint{-\pgfarrowlength}{0.5\pgflinewidth}}
   \pgfpathcurveto{\pgfpoint{-0.75\pgfarrowlength}{0.6\pgflinewidth}}{%
   \pgfpoint{-0.01\pgfarrowlength}{0.6\pgflinewidth}}{%
   \pgfpoint{0pt}{0pt}}
   \pgfpathcurveto{\pgfpoint{-0.01\pgfarrowlength}{-0.5\pgflinewidth}}{%
   \pgfpoint{-0.2\pgfarrowlength}{-(1+0.3*rnd)*\pgflinewidth}}{%
   \pgfpoint{-0.3\pgfarrowlength}{-0.8*(1+0.3*rnd)*\pgflinewidth}}
   \pgfpathcurveto{\pgfpoint{-0.4\pgfarrowlength}{-0.6*(1+0.3*rnd)*\pgflinewidth}}{%
   \pgfpoint{-0.6\pgfarrowlength}{-0.3*(1+0.3*rnd)*\pgflinewidth}}{%
   \pgfpoint{-1\pgfarrowlength}{-0.5\pgflinewidth}}
   \pgfusepathqfill
  },
  defaults = {length=14pt}
}
\tikzset{handdrawn/.style={
        decorate,
        decoration={
            show path construction,
            lineto code={
                 \draw[
                 shorten >={(-3*rnd)*1pt},
                 shorten <={(-3*rnd)*1pt}]
                 let \p1=($(\tikzinputsegmentlast)-(\tikzinputsegmentfirst)$),
                 \n1={90+atan2(\y1,\x1)} in
                 ($(\tikzinputsegmentfirst)+(\n1:{(1.02-0.04*rnd)*0pt})$)
                 --
                ($(\tikzinputsegmentlast)+(\n1:{(1.02-0.04*rnd)*0pt})$);
            },
            curveto code={
                 \draw[{ink[bend]}-{ink[bend]},shorten >={(-3*rnd)*1pt},
                 shorten <={(-3*rnd)*1pt}]
                 let \p1=($(\tikzinputsegmentsupporta)-(\tikzinputsegmentfirst)$),
                 \p2=($(\tikzinputsegmentsupportb)-(\tikzinputsegmentsupporta)$),
                 \p3=($(\tikzinputsegmentlast)-(\tikzinputsegmentsupportb)$),
                 \n1={90+atan2(\y1,\x1)}, \n2={90+atan2(\y2,\x2)}, 
                 \n3={90+atan2(\y3,\x3)} in
                 ($(\tikzinputsegmentfirst)+(\n1:{(1.02-0.04*rnd)*0pt})$)
                 .. controls
                 ($(\tikzinputsegmentsupporta)+(\n2:{(1.02-0.04*rnd)*0.1pt})$)
                  and ($(\tikzinputsegmentsupportb)+(\n3:{(1.02-0.04*rnd)*0.1pt})$) ..
                ($(\tikzinputsegmentlast)+(\n3:{(1.02-0.04*rnd)*0pt})$);
            },
            closepath code={
%                  \draw[{ink[bend]}-{ink[bend]},shorten >={(-4*rnd)*0.1pt},
%                  shorten <={(-4*rnd)*0.1pt}]
%                  let \p1=($(\tikzinputsegmentsupporta)-(\tikzinputsegmentfirst)$),
%                  \p2=($(\tikzinputsegmentsupportb)-(\tikzinputsegmentsupporta)$),
%                  \p3=($(\tikzinputsegmentlast)-(\tikzinputsegmentsupportb)$),
%                  \n1={90+atan2(\y1,\x1)}, \n2={90+atan2(\y2,\x2)}, 
%                  \n3={90+atan2(\y3,\x3)} in
%                  ($(\tikzinputsegmentfirst)+(\n1:{(1.02-0.04*rnd)*0.1pt})$)
%                  .. controls ($(\tikzinputsegmentsupporta)+(\n2:{(1.02-0.04*rnd)*0.1pt})$)
%                   and ($(\tikzinputsegmentsupportb)+(\n3:{(1.02-0.04*rnd)*0.1pt})$) ..
%                 ($(\tikzinputsegmentlast)+(\n3:{(1.02-0.04*rnd)*0.1pt})$);
            },
        }
    }}

\begin{document}
\begin{tikzpicture}
 \node[postaction={draw,handdrawn,very thick},draw,very thick,
 fill=orange!40,rounded rectangle,inner sep=1em]{pft};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容