Customizing \fill and line in TikZ
Here's a start, based on my answer at Handwritten comments and annotations in margin. There, I make use of the Teen SPirit font, which is a handwritten font (by way of \fontfamily{fts}\selectfont
). Looking at the glyph set of that font (page 2 of http://www.tug.dk/FontCatalogue/teenspirit/teenspirit.pdf), there are several choices for hand drawn line (e.g., glyphs 40, 47, 73, 108, 124, etc.). I chose glyph 47
Then, I created the macro \handxform
for rotating and scaling a glyph, where the vertical scale is given by a factor and the horizontal scale is given by a desired length (EDITED to work around scaling limitation, so that actual width specified is honored). The macro \handline[<thickness-scale>]{<length>}
passes glyph 47 to \handxform
, along with the user-specified scaling information, and the rotations necessary to turn glyph 47 into a horizontal aspect at the proper elevation.
All of the handdrawn lines in the MWE below are scaled, rotated versions of glyph 47.
EDITED to add \handstealthleftrightarrow[<thickness-scale>]{<length>}
to the mix, by stringing together glyph 60 and its mirror image:
EDITED to add \handbox[<thickness-scale>]{<length>}{<height>}
, which works by stringing together 4 \handline
s.
\documentclass{beamer}
\usepackage{tikz}
\usetheme{CambridgeUS}
\usetikzlibrary{calc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usetikzlibrary{arrows.meta} %
\tikzset{vvnode/.style={color=gray!50!black!50,text=black , line width=4pt}}
\newcommand{\uline}[2][blue!30!red]{
\setbox0=\hbox{#2}%
\stackunder[2pt]{\copy0}{\color{#1}\handline[2]{\wd0}}%
}
\usepackage{emerald,scalerel,stackengine}
\usepackage[T1]{fontenc}
\newcommand\handline[2][1]{%
\kern-.25ex\smash{\handxform{0ex}{-.32ex}{90}{15}{47}{#1}{#2}}}
\newcommand\handstealthrightarrow[2][1]{%
\handxform{.51ex}{-0.2ex}{ 90}{ 80}{60}{#1}{#2}}
\newcommand\handstealthleftarrow [2][1]{%
\handxform{.49ex}{0.40ex}{-90}{ 80}{60}{#1}{#2}}
\newcommand\handstealthleftrightarrow[2][1]{%
\handstealthleftarrow[#1]{.5\dimexpr#2}\kern-0.11\dimexpr#2\relax%
\handstealthrightarrow[#1]{.5\dimexpr#2}}
\newcommand\handbox[3][1]{%
\rotatebox{90}{\handline[#1]{#3}}\kern-.006\dimexpr#1\dimexpr#2\relax\relax%
\stackon[\dimexpr1\dimexpr#3\relax-\dimexpr.6ex]{\handline[#1]{#2}}{%
\handline[#1]{#2}}%
\kern-#1\dimexpr.3ex%
\rotatebox{90}{\handline[#1]{#3}}%
}
\newcommand\handxform[7]{%
\raisebox{#1}{\fontfamily{fts}\selectfont\scalebox{4}[#6]{%
\raisebox{#2}{\rotatebox{#3}{\stretchto{\rotatebox{#4}{\char#5}}{.25\dimexpr#7}}}}}}
\begin{document}
\begin{frame}{}
\begin{tikzpicture}
\node[ ] at (0,0) {\rlap{\color{blue!20}\handline[24]{3.3in}}
$\left(\frac\delta{\delta h_0}-2m \frac\delta{\delta F_0} \right)S=0,\quad
\left(\frac\delta{\delta \tau_0}-m \frac\delta{\delta \chi_0} \right)S=0 $};
\end{tikzpicture}\smallskip
\begin{tikzpicture}[]%remember picture
\node at (0,0) {
\begin{tikzpicture}
\node[ vvnode,name=bbb,align=left] at (-1,-2) {Operators\\
$\begin{aligned}\mathcal O=& O_\theta + \theta \uline{$O_\chi$} +\theta^2 \uline{$O_F$} \\
\mathcal F\mathcal Z=& \left\{ \uline{$T_{\mu\nu}$}, \uline{$S_\mu$}, j_\mu\right\}
\end{aligned} $};
\node at (2.7,-2) {\color{gray}\handstealthleftrightarrow[2]{1in}};%
\node at (2.2,-2) {\color{gray}\handbox[5]{4.7in}{1in}};
\node[ vvnode,align=left] at (5.9,-2) {$5d$ fields\\
$\begin{aligned} \mathcal H=& \left\{ \phi, \uline{$\chi$}, \uline{$F$} \right\} \\
\mathcal G=& \left\{ \uline{$g_{\mu\nu}$}, \uline{$\Psi_\mu$}, A_\mu\right\}
\end{aligned} $};
\end{tikzpicture}
};
\end{tikzpicture}
\end{frame}
\begin{frame}
\handbox[3]{2.5in}{.7in}\quad
\handbox[1]{1in}{.7in}\medskip
\handbox[5]{4.5in}{.7in}
\handstealthleftrightarrow[1]{.5in}
\handstealthleftrightarrow[3]{3in}
\mbox{}\handline[1]{1in}
\handline[10]{1in}
\handline[5]{1in}
\the\textwidth
\noindent\fbox{\rule{.9\textwidth}{1pt}}
\noindent\fbox{\handline[1]{.9\textwidth}}
\end{frame}
\end{document}
DISCUSSION
There are some questions below on how to tune the particular shape of the "swish." However, that belies a fundamental misunderstanding of what is done here. All that I am doing is taking a font's glyph, and rotating/stretching/rerotating/translating/restretching/retranslating it, to achieve a desired size and orientation. The shape of the swish is driven totally by the original glyph selected, which in this answer came from the Teen Spirit font.
As an example, if I redefine \handxform
to not use the Teen Spirit font, and to instead of the specified glyph, use a simple \rule{1pt}{5pt}
:
\newcommand\handxform[7]{%
\raisebox{#1}{\scalebox{4}[#6]{%
\raisebox{#2}{\rotatebox{#3}{\stretchto{\rotatebox{#4}{\rule{1pt}{5pt}}}{.25\dimexpr#7}}}}}}
you will see the results change accordingly, where the new swish is comprised of a transformed \rule
instead of a transformed glyph 47 or 60.
Therefore, to obtain other shapes, other suitable glyphs must be found from other fonts, if this technique is to be employed. Alternately, someone could use tikz
to design a desired swish, and that could be incorporated into a slightly redefined \handxform
macro.
As an illustrative case, I can even use an \includegraphics
as the swish. Idealy it would be a transparent png, but here I just took the image at the top of this page, saved it as a jpeg, tried to expunge the black text, and used that as my swish. Obviously, the definitions and parameters had to be reworked to accommodate this (especially since the aspect ratio is different), but the result looks as expected:
After saving a large version of the image as greenswish.jpg
, The code for the above is:
\documentclass{beamer}
\usepackage{tikz}
\usetheme{CambridgeUS}
\usetikzlibrary{calc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usetikzlibrary{arrows.meta} %
\tikzset{vvnode/.style={color=gray!50!black!50,text=black , line width=4pt}}
\newcommand{\uline}[2][blue!30!red]{
\setbox0=\hbox{#2}%
\stackunder[2pt]{\copy0}{\color{#1}\handline[.2]{\wd0}}%
}
\usepackage{emerald,scalerel,stackengine}
\usepackage[T1]{fontenc}
\newcommand\handline[2][.1]{%
\kern-.2ex\smash{\handxform{.0ex}{.6ex}{-90}{90}{%
\includegraphics[scale=.1]{greenswish}}{#1}{#2}}}
\newcommand\handstealthrightarrow[2][1]{%
\handxform{.51ex}{-0.2ex}{ 90}{ 80}{\char60}{#1}{#2}}
\newcommand\handstealthleftarrow [2][1]{%
\handxform{.49ex}{0.40ex}{-90}{ 80}{\char60}{#1}{#2}}
\newcommand\handstealthleftrightarrow[2][1]{%
\handstealthleftarrow[#1]{.5\dimexpr#2}\kern-0.11\dimexpr#2\relax%
\handstealthrightarrow[#1]{.5\dimexpr#2}}
\newcommand\handbox[3][.1]{%
\rotatebox{90}{\handline[#1]{#3}}\kern-.006\dimexpr#1\dimexpr#2\relax\relax%
\stackon[\dimexpr1\dimexpr#3\relax+.4ex]{\handline[#1]{#2}}{%
\handline[#1]{#2}}%
\kern-#1\dimexpr.3ex%
\rotatebox{90}{\handline[#1]{#3}}%
}
\newcommand\handxform[7]{%
\raisebox{#1}{\fontfamily{fts}\selectfont\scalebox{4}[#6]{%
\raisebox{#2}{\rotatebox{#3}{\stretchto{\rotatebox{#4}{#5}}{.25\dimexpr#7}}}}}}
\begin{document}
\begin{frame}{}
\begin{tikzpicture}
\node[ ] at (0,0) {\rlap{\color{blue!20}\handline[3]{3.42in}}
$\left(\frac\delta{\delta h_0}-2m \frac\delta{\delta F_0} \right)S=0,\quad
\left(\frac\delta{\delta \tau_0}-m \frac\delta{\delta \chi_0} \right)S=0 $};
\end{tikzpicture}\smallskip
\begin{tikzpicture}[]%remember picture
\node at (0,0) {
\begin{tikzpicture}
\node[ vvnode,name=bbb,align=left] at (-1,-2) {Operators\\
$\begin{aligned}\mathcal O=& O_\theta + \theta \uline{$O_\chi$} +\theta^2 \uline{$O_F$} \\
\mathcal F\mathcal Z=& \left\{ \uline{$T_{\mu\nu}$}, \uline{$S_\mu$}, j_\mu\right\}
\end{aligned} $};
\node at (2.7,-2) {\color{gray}\handstealthleftrightarrow[2]{1in}};%
\node at (2.2,-2) {\color{gray}\handbox[.5]{4.7in}{1in}};
\node[ vvnode,align=left] at (5.9,-2) {$5d$ fields\\
$\begin{aligned} \mathcal H=& \left\{ \phi, \uline{$\chi$}, \uline{$F$} \right\} \\
\mathcal G=& \left\{ \uline{$g_{\mu\nu}$}, \uline{$\Psi_\mu$}, A_\mu\right\}
\end{aligned} $};
\end{tikzpicture}
};
\end{tikzpicture}
\end{frame}
\begin{frame}
\handbox[.3]{2.5in}{.7in}\quad
\handbox[.1]{1in}{.7in}\medskip
\handbox[.1]{4.5in}{.7in}
\handstealthleftrightarrow[.1]{.5in}
\handstealthleftrightarrow[.3]{3in}
\mbox{}\handline[.1]{1in}
\handline[1.0]{1in}
\handline[.5]{1in}
\the\textwidth
\noindent\fbox{\rule{.9\textwidth}{1pt}}
\noindent\fbox{\handline[.1]{.9\textwidth}}
\end{frame}
\end{document}
Here's an incomplete and very minimal demonstration of the kind of thing you might do, which is still rather time-consuming to achieve for all its abject failure to fulfil the desiderata.
The following code creates a fairly minimal pic
called brush stroke
. It accepts a list of key-value options. The options implemented below are colour
, text
and name
.
The pic
creates the node and then scales a scoped and filled path based on a stroke vector from Lazur URH's work at https://openclipart.org/detail/211152/brush-stroke-2, extracted and exported to TikZ code using Inkscape. I edited this code a bit and turned the filling colour into a variable which picks up the colour
option and makes it partially transparent.
\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{backgrounds}
\makeatletter
\tikzset{%
pics/brush stroke/.style={%
code={%
\tikzset{%
brushes/.cd,
#1,
}
\node (\brushes@name) [anchor=west, pic actions] {\brushes@text};
\pgfmathsetmacro\brushes@textwidth{((width("\brushes@text"))+40pt)/112mm}
\pgfmathsetmacro\brushes@texttotalheight{((height("\brushes@text")+depth("\brushes@text"))+10pt)/15mm}
% based on stroke from Lazur URH's work at https://openclipart.org/detail/211152/brush-stroke-2, extracted and exported using Inkscape
\begin{scope}[on background layer, y=0.8pt, x=0.8pt, xscale=\brushes@textwidth, yscale=\brushes@texttotalheight, yshift=-100+5pt, xshift=-10pt]
\path [fill=\brushes@colour, fill opacity=.2, pic actions] (2.5,85.29) .. controls (1.1193,85.29) and (0,86.4093) .. (0,87.79) .. controls (0,89.1707) and (1.1193,90.29) .. (2.5,90.29) .. controls (72.08,90.29) and (316.55,88.4202) .. (400,87.79) .. controls (316.548,87.1598) and (72.08,85.29) .. (2.5,85.29) -- cycle(2.5,88.8614) .. controls (1.1193,88.8614) and (0,89.9807) .. (0,91.3614) .. controls (0,92.7421) and (1.1193,93.8614) .. (2.5,93.8614) .. controls (72.08,93.8614) and (316.55,91.9916) .. (400,91.3614) .. controls (316.548,90.7312) and (72.08,88.8614) .. (2.5,88.8614) -- cycle(2.5,92.4328) .. controls (1.1193,92.4328) and (0,93.5521) .. (0,94.9328) .. controls (0,96.3135) and (1.1193,97.4328) .. (2.5,97.4328) .. controls (72.08,97.4328) and (316.55,95.563) .. (400,94.9328) .. controls (316.548,94.3026) and (72.08,92.4328) .. (2.5,92.4328) -- cycle(2.5,96.0042) .. controls (1.1193,96.0042) and (0,97.1235) .. (0,98.5042) .. controls (0,99.8849) and (1.1193,101.0042) .. (2.5,101.0042) .. controls (72.08,101.0042) and (316.55,99.1344) .. (400,98.5042) .. controls (316.548,97.874) and (72.08,96.0042) .. (2.5,96.0042) -- cycle(2.5,99.5756) .. controls (1.1193,99.5756) and (0,100.6949) .. (0,102.0756) .. controls (0,103.4563) and (1.1193,104.5756) .. (2.5,104.5756) .. controls (72.08,104.5756) and (316.55,102.7058) .. (400,102.0756) .. controls (316.548,101.4454) and (72.08,99.5756) .. (2.5,99.5756) -- cycle(2.5,103.147) .. controls (1.1193,103.147) and (0,104.2663) .. (0,105.647) .. controls (0,107.0277) and (1.1193,108.147) .. (2.5,108.147) .. controls (72.08,108.147) and (316.55,106.2772) .. (400,105.647) .. controls (316.548,105.0168) and (72.08,103.147) .. (2.5,103.147) -- cycle(2.5,106.7184) .. controls (1.1193,106.7184) and (0,107.8377) .. (0,109.2184) .. controls (0,110.5991) and (1.1193,111.7184) .. (2.5,111.7184) .. controls (72.08,111.7184) and (316.55,109.8486) .. (400,109.2184) .. controls (316.548,108.5882) and (72.08,106.7184) .. (2.5,106.7184) -- cycle(2.5,110.2898) .. controls (1.1193,110.2898) and (0,111.4091) .. (0,112.7898) .. controls (0,114.1705) and (1.1193,115.2898) .. (2.5,115.2898) .. controls (72.08,115.2898) and (316.55,113.42) .. (400,112.7898) .. controls (316.548,112.1596) and (72.08,110.2898) .. (2.5,110.2898) -- cycle(2.5,113.8612) .. controls (1.1193,113.8612) and (0,114.9805) .. (0,116.3612) .. controls (0,117.7419) and (1.1193,118.8612) .. (2.5,118.8612) .. controls (72.08,118.8612) and (316.55,116.9914) .. (400,116.3612) .. controls (316.548,115.731) and (72.08,113.8612) .. (2.5,113.8612) -- cycle(2.5,117.4326) .. controls (1.1193,117.4326) and (0,118.5519) .. (0,119.9326) .. controls (0,121.3133) and (1.1193,122.4326) .. (2.5,122.4326) .. controls (72.08,122.4326) and (316.55,120.5628) .. (400,119.9326) .. controls (316.548,119.3024) and (72.08,117.4326) .. (2.5,117.4326) -- cycle(2.5,121.004) .. controls (1.1193,121.004) and (0,122.1233) .. (0,123.504) .. controls (0,124.8847) and (1.1193,126.004) .. (2.5,126.004) .. controls (72.08,126.004) and (316.55,124.1342) .. (400,123.504) .. controls (316.548,122.8738) and (72.08,121.004) .. (2.5,121.004) -- cycle(2.5,124.5754) .. controls (1.1193,124.5754) and (0,125.6947) .. (0,127.0754) .. controls (0,128.4561) and (1.1193,129.5754) .. (2.5,129.5754) .. controls (72.08,129.5754) and (316.55,127.7056) .. (400,127.0754) .. controls (316.548,126.4452) and (72.08,124.5754) .. (2.5,124.5754) -- cycle(2.5,128.1468) .. controls (1.1193,128.1468) and (0,129.2661) .. (0,130.6468) .. controls (0,132.0275) and (1.1193,133.1468) .. (2.5,133.1468) .. controls (72.08,133.1468) and (316.55,131.277) .. (400,130.6468) .. controls (316.548,130.0166) and (72.08,128.1468) .. (2.5,128.1468) -- cycle(2.5,131.7182) .. controls (1.1193,131.7182) and (0,132.8375) .. (0,134.2182) .. controls (0,135.5989) and (1.1193,136.7182) .. (2.5,136.7182) .. controls (72.08,136.7182) and (316.55,134.8484) .. (400,134.2182) .. controls (316.548,133.588) and (72.08,131.7182) .. (2.5,131.7182) -- cycle(2.5,135.2896) .. controls (1.1193,135.2896) and (0,136.4089) .. (0,137.7896) .. controls (0,139.1703) and (1.1193,140.2896) .. (2.5,140.2896) .. controls (72.08,140.2896) and (316.55,138.4198) .. (400,137.7896) .. controls (316.548,137.1594) and (72.08,135.2896) .. (2.5,135.2896) -- cycle;
\end{scope}
},
},
brushes/.search also={/tikz},
brushes/.cd,
name/.store in=\brushes@name,
colour/.store in=\brushes@colour,
text/.store in=\brushes@text,
name=brush node,
colour=green,
text=,
}
\makeatother
\begin{document}
\begin{tikzpicture}
\pic at (0,0) {brush stroke={text=This is some text.}};
\pic [font=\sffamily\large] at (0,1) {brush stroke={text=This is some more text., colour=blue, blue}};
\end{tikzpicture}
\end{document}
The rather pedestrian result:
EDIT
Here's a rather poorly coordinated example, just for demonstration, which combines the above with customised arrows and the pencil draw
decoration from Claudio Fiandrino's answer.
\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{backgrounds,decorations.pathmorphing,fit,arrows.meta,bending}
\tikzset{pencil draw/.style={% code from Claudio Fiandrino's answer at https://tex.stackexchange.com/a/95333/
draw,
decorate,
decoration={random steps, segment length=3mm, amplitude=0.2mm}
},
}
\makeatletter
\tikzset{%
pics/brush stroke/.style={%
code={%
\tikzset{%
brushes/.cd,
#1,
}
\begin{scope}[local bounding box/.expanded=\brushes@name]
\node (\brushes@name-text) [anchor=west, pic actions] {\brushes@text};
\pgfmathsetmacro\brushes@textwidth{((width("\brushes@text"))+40pt)/112mm}
\pgfmathsetmacro\brushes@texttotalheight{((height("\brushes@text")+depth("\brushes@text"))+10pt)/15mm}
% based on stroke from Lazur URH's work at https://openclipart.org/detail/211152/brush-stroke-2, extracted and exported using Inkscape
\begin{scope}[on background layer, y=0.8pt, x=0.8pt, xscale=\brushes@textwidth, yscale=\brushes@texttotalheight, yshift=-100+5pt, xshift=-10pt]
\path [fill=\brushes@colour, fill opacity=.2, pic actions] (2.5,85.29) .. controls (1.1193,85.29) and (0,86.4093) .. (0,87.79) .. controls (0,89.1707) and (1.1193,90.29) .. (2.5,90.29) .. controls (72.08,90.29) and (316.55,88.4202) .. (400,87.79) .. controls (316.548,87.1598) and (72.08,85.29) .. (2.5,85.29) -- cycle(2.5,88.8614) .. controls (1.1193,88.8614) and (0,89.9807) .. (0,91.3614) .. controls (0,92.7421) and (1.1193,93.8614) .. (2.5,93.8614) .. controls (72.08,93.8614) and (316.55,91.9916) .. (400,91.3614) .. controls (316.548,90.7312) and (72.08,88.8614) .. (2.5,88.8614) -- cycle(2.5,92.4328) .. controls (1.1193,92.4328) and (0,93.5521) .. (0,94.9328) .. controls (0,96.3135) and (1.1193,97.4328) .. (2.5,97.4328) .. controls (72.08,97.4328) and (316.55,95.563) .. (400,94.9328) .. controls (316.548,94.3026) and (72.08,92.4328) .. (2.5,92.4328) -- cycle(2.5,96.0042) .. controls (1.1193,96.0042) and (0,97.1235) .. (0,98.5042) .. controls (0,99.8849) and (1.1193,101.0042) .. (2.5,101.0042) .. controls (72.08,101.0042) and (316.55,99.1344) .. (400,98.5042) .. controls (316.548,97.874) and (72.08,96.0042) .. (2.5,96.0042) -- cycle(2.5,99.5756) .. controls (1.1193,99.5756) and (0,100.6949) .. (0,102.0756) .. controls (0,103.4563) and (1.1193,104.5756) .. (2.5,104.5756) .. controls (72.08,104.5756) and (316.55,102.7058) .. (400,102.0756) .. controls (316.548,101.4454) and (72.08,99.5756) .. (2.5,99.5756) -- cycle(2.5,103.147) .. controls (1.1193,103.147) and (0,104.2663) .. (0,105.647) .. controls (0,107.0277) and (1.1193,108.147) .. (2.5,108.147) .. controls (72.08,108.147) and (316.55,106.2772) .. (400,105.647) .. controls (316.548,105.0168) and (72.08,103.147) .. (2.5,103.147) -- cycle(2.5,106.7184) .. controls (1.1193,106.7184) and (0,107.8377) .. (0,109.2184) .. controls (0,110.5991) and (1.1193,111.7184) .. (2.5,111.7184) .. controls (72.08,111.7184) and (316.55,109.8486) .. (400,109.2184) .. controls (316.548,108.5882) and (72.08,106.7184) .. (2.5,106.7184) -- cycle(2.5,110.2898) .. controls (1.1193,110.2898) and (0,111.4091) .. (0,112.7898) .. controls (0,114.1705) and (1.1193,115.2898) .. (2.5,115.2898) .. controls (72.08,115.2898) and (316.55,113.42) .. (400,112.7898) .. controls (316.548,112.1596) and (72.08,110.2898) .. (2.5,110.2898) -- cycle(2.5,113.8612) .. controls (1.1193,113.8612) and (0,114.9805) .. (0,116.3612) .. controls (0,117.7419) and (1.1193,118.8612) .. (2.5,118.8612) .. controls (72.08,118.8612) and (316.55,116.9914) .. (400,116.3612) .. controls (316.548,115.731) and (72.08,113.8612) .. (2.5,113.8612) -- cycle(2.5,117.4326) .. controls (1.1193,117.4326) and (0,118.5519) .. (0,119.9326) .. controls (0,121.3133) and (1.1193,122.4326) .. (2.5,122.4326) .. controls (72.08,122.4326) and (316.55,120.5628) .. (400,119.9326) .. controls (316.548,119.3024) and (72.08,117.4326) .. (2.5,117.4326) -- cycle(2.5,121.004) .. controls (1.1193,121.004) and (0,122.1233) .. (0,123.504) .. controls (0,124.8847) and (1.1193,126.004) .. (2.5,126.004) .. controls (72.08,126.004) and (316.55,124.1342) .. (400,123.504) .. controls (316.548,122.8738) and (72.08,121.004) .. (2.5,121.004) -- cycle(2.5,124.5754) .. controls (1.1193,124.5754) and (0,125.6947) .. (0,127.0754) .. controls (0,128.4561) and (1.1193,129.5754) .. (2.5,129.5754) .. controls (72.08,129.5754) and (316.55,127.7056) .. (400,127.0754) .. controls (316.548,126.4452) and (72.08,124.5754) .. (2.5,124.5754) -- cycle(2.5,128.1468) .. controls (1.1193,128.1468) and (0,129.2661) .. (0,130.6468) .. controls (0,132.0275) and (1.1193,133.1468) .. (2.5,133.1468) .. controls (72.08,133.1468) and (316.55,131.277) .. (400,130.6468) .. controls (316.548,130.0166) and (72.08,128.1468) .. (2.5,128.1468) -- cycle(2.5,131.7182) .. controls (1.1193,131.7182) and (0,132.8375) .. (0,134.2182) .. controls (0,135.5989) and (1.1193,136.7182) .. (2.5,136.7182) .. controls (72.08,136.7182) and (316.55,134.8484) .. (400,134.2182) .. controls (316.548,133.588) and (72.08,131.7182) .. (2.5,131.7182) -- cycle(2.5,135.2896) .. controls (1.1193,135.2896) and (0,136.4089) .. (0,137.7896) .. controls (0,139.1703) and (1.1193,140.2896) .. (2.5,140.2896) .. controls (72.08,140.2896) and (316.55,138.4198) .. (400,137.7896) .. controls (316.548,137.1594) and (72.08,135.2896) .. (2.5,135.2896) -- cycle;
\end{scope}
\end{scope}
},
},
brushes/.search also={/tikz},
brushes/.cd,
name/.store in=\brushes@name,
colour/.store in=\brushes@colour,
text/.store in=\brushes@text,
name=brush node,
colour=green,
text=,
/tikz/.cd,
thin pencil/.style={draw=#1!75!gray, pencil draw},
thick pencil/.style={draw=#1!75!gray!50, pencil draw, line width=1pt},
thin arrow/.style={draw=#1!75!gray, >={Triangle[bend]}},
thick arrow/.style={draw=#1!75!gray, >={Triangle[bend]}, line width=1pt},
}
\makeatother
\begin{document}
\begin{tikzpicture}
\pic at (0,0) {brush stroke={name=this, text=This is some text.}};
\pic [font=\sffamily\large] at (0,1) {brush stroke={name=that, text=This is some more text., colour=blue, blue}};
\node [thick pencil=blue, fit=(that)] {};
\node [thick pencil=green, fit=(this)] {};
\draw [thin arrow=blue, ->] (that-text.east) [bend left=45] to ++(.5,-.75) node [thin pencil=blue, anchor=north] {$c^2$};
\draw [thick arrow=magenta, <->] ([xshift=3pt]this-text.west) [out=180, in=180] to ([xshift=3pt]that-text.west);
\node [fit=(current bounding box), pencil draw, line width=1pt, double=gray!10, draw=gray] {};
\end{tikzpicture}
\end{document}
EDIT EDIT
Here is a version which this time uses code from Alain Matthes's answer for the hand-hewn look. This kind-of-partially-supports-rounding-if-you-are-very-careful-and-like-to-live-dangerously. (If you get too large dimension errors, you've exceeded TikZ's limits. Unsurprisingly, this can vary randomly. Hence, success on one run does not guarantee success on the next with the same code!)
\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{backgrounds,decorations.pathmorphing,fit,arrows.meta,bending}
\makeatletter
\tikzset{%
pics/brush stroke/.style={%
code={%
\tikzset{%
brushes/.cd,
#1,
}
\begin{scope}[local bounding box/.expanded=\brushes@name]
\node (\brushes@name-text) [anchor=west, pic actions] {\brushes@text};
\pgfmathsetmacro\brushes@textwidth{((width("\brushes@text"))+40pt)/112mm}
\pgfmathsetmacro\brushes@texttotalheight{((height("\brushes@text")+depth("\brushes@text"))+10pt)/15mm}
% based on stroke from Lazur URH's work at https://openclipart.org/detail/211152/brush-stroke-2, extracted and exported using Inkscape
\begin{scope}[on background layer, y=0.8pt, x=0.8pt, xscale=\brushes@textwidth, yscale=\brushes@texttotalheight, yshift=-100+5pt, xshift=-10pt]
\path [fill=\brushes@colour, fill opacity=.2, pic actions] (2.5,85.29) .. controls (1.1193,85.29) and (0,86.4093) .. (0,87.79) .. controls (0,89.1707) and (1.1193,90.29) .. (2.5,90.29) .. controls (72.08,90.29) and (316.55,88.4202) .. (400,87.79) .. controls (316.548,87.1598) and (72.08,85.29) .. (2.5,85.29) -- cycle(2.5,88.8614) .. controls (1.1193,88.8614) and (0,89.9807) .. (0,91.3614) .. controls (0,92.7421) and (1.1193,93.8614) .. (2.5,93.8614) .. controls (72.08,93.8614) and (316.55,91.9916) .. (400,91.3614) .. controls (316.548,90.7312) and (72.08,88.8614) .. (2.5,88.8614) -- cycle(2.5,92.4328) .. controls (1.1193,92.4328) and (0,93.5521) .. (0,94.9328) .. controls (0,96.3135) and (1.1193,97.4328) .. (2.5,97.4328) .. controls (72.08,97.4328) and (316.55,95.563) .. (400,94.9328) .. controls (316.548,94.3026) and (72.08,92.4328) .. (2.5,92.4328) -- cycle(2.5,96.0042) .. controls (1.1193,96.0042) and (0,97.1235) .. (0,98.5042) .. controls (0,99.8849) and (1.1193,101.0042) .. (2.5,101.0042) .. controls (72.08,101.0042) and (316.55,99.1344) .. (400,98.5042) .. controls (316.548,97.874) and (72.08,96.0042) .. (2.5,96.0042) -- cycle(2.5,99.5756) .. controls (1.1193,99.5756) and (0,100.6949) .. (0,102.0756) .. controls (0,103.4563) and (1.1193,104.5756) .. (2.5,104.5756) .. controls (72.08,104.5756) and (316.55,102.7058) .. (400,102.0756) .. controls (316.548,101.4454) and (72.08,99.5756) .. (2.5,99.5756) -- cycle(2.5,103.147) .. controls (1.1193,103.147) and (0,104.2663) .. (0,105.647) .. controls (0,107.0277) and (1.1193,108.147) .. (2.5,108.147) .. controls (72.08,108.147) and (316.55,106.2772) .. (400,105.647) .. controls (316.548,105.0168) and (72.08,103.147) .. (2.5,103.147) -- cycle(2.5,106.7184) .. controls (1.1193,106.7184) and (0,107.8377) .. (0,109.2184) .. controls (0,110.5991) and (1.1193,111.7184) .. (2.5,111.7184) .. controls (72.08,111.7184) and (316.55,109.8486) .. (400,109.2184) .. controls (316.548,108.5882) and (72.08,106.7184) .. (2.5,106.7184) -- cycle(2.5,110.2898) .. controls (1.1193,110.2898) and (0,111.4091) .. (0,112.7898) .. controls (0,114.1705) and (1.1193,115.2898) .. (2.5,115.2898) .. controls (72.08,115.2898) and (316.55,113.42) .. (400,112.7898) .. controls (316.548,112.1596) and (72.08,110.2898) .. (2.5,110.2898) -- cycle(2.5,113.8612) .. controls (1.1193,113.8612) and (0,114.9805) .. (0,116.3612) .. controls (0,117.7419) and (1.1193,118.8612) .. (2.5,118.8612) .. controls (72.08,118.8612) and (316.55,116.9914) .. (400,116.3612) .. controls (316.548,115.731) and (72.08,113.8612) .. (2.5,113.8612) -- cycle(2.5,117.4326) .. controls (1.1193,117.4326) and (0,118.5519) .. (0,119.9326) .. controls (0,121.3133) and (1.1193,122.4326) .. (2.5,122.4326) .. controls (72.08,122.4326) and (316.55,120.5628) .. (400,119.9326) .. controls (316.548,119.3024) and (72.08,117.4326) .. (2.5,117.4326) -- cycle(2.5,121.004) .. controls (1.1193,121.004) and (0,122.1233) .. (0,123.504) .. controls (0,124.8847) and (1.1193,126.004) .. (2.5,126.004) .. controls (72.08,126.004) and (316.55,124.1342) .. (400,123.504) .. controls (316.548,122.8738) and (72.08,121.004) .. (2.5,121.004) -- cycle(2.5,124.5754) .. controls (1.1193,124.5754) and (0,125.6947) .. (0,127.0754) .. controls (0,128.4561) and (1.1193,129.5754) .. (2.5,129.5754) .. controls (72.08,129.5754) and (316.55,127.7056) .. (400,127.0754) .. controls (316.548,126.4452) and (72.08,124.5754) .. (2.5,124.5754) -- cycle(2.5,128.1468) .. controls (1.1193,128.1468) and (0,129.2661) .. (0,130.6468) .. controls (0,132.0275) and (1.1193,133.1468) .. (2.5,133.1468) .. controls (72.08,133.1468) and (316.55,131.277) .. (400,130.6468) .. controls (316.548,130.0166) and (72.08,128.1468) .. (2.5,128.1468) -- cycle(2.5,131.7182) .. controls (1.1193,131.7182) and (0,132.8375) .. (0,134.2182) .. controls (0,135.5989) and (1.1193,136.7182) .. (2.5,136.7182) .. controls (72.08,136.7182) and (316.55,134.8484) .. (400,134.2182) .. controls (316.548,133.588) and (72.08,131.7182) .. (2.5,131.7182) -- cycle(2.5,135.2896) .. controls (1.1193,135.2896) and (0,136.4089) .. (0,137.7896) .. controls (0,139.1703) and (1.1193,140.2896) .. (2.5,140.2896) .. controls (72.08,140.2896) and (316.55,138.4198) .. (400,137.7896) .. controls (316.548,137.1594) and (72.08,135.2896) .. (2.5,135.2896) -- cycle;
\end{scope}
\end{scope}
},
},
brushes/.search also={/tikz},
brushes/.cd,
name/.store in=\brushes@name,
colour/.store in=\brushes@colour,
text/.store in=\brushes@text,
name=brush node,
colour=green,
text=,
}
\makeatother
% code from Alain Matthes's answer at https://tex.stackexchange.com/a/49272/
\pgfdeclaredecoration{free hand}{start}
{
\state{start}[width = +0pt,
next state=step,
persistent precomputation = \pgfdecoratepathhascornerstrue]{}
\state{step}[auto end on length = 3pt,
auto corner on length = 3pt,
width=+2pt]
{
\pgfpathlineto{
\pgfpointadd
{\pgfpoint{2pt}{0pt}}
{\pgfpoint{rand*0.15pt}{rand*0.15pt}}
}
}
\state{final}
{}
}
\tikzset{free hand/.style={
decorate,
decoration={free hand}
}
}
\newcommand\freedraw{\draw [free hand]}
\tikzset{%
thin arrow/.style={draw=#1!75!gray, >={Triangle[bend]}},
thick arrow/.style={draw=#1!75!gray, >={Triangle[bend]}, line width=1pt},
thin free hand/.style={draw=#1!75!gray, free hand},
thick free hand/.style={draw=#1!71!gray!50, free hand, line width=1pt},
}
\begin{document}
\begin{tikzpicture}
\pic at (0,0) {brush stroke={name=this, text=This is some text.}};
\pic [font=\sffamily\large] at (0,1) {brush stroke={name=that, text=This is some more text., colour=blue, blue}};
\node [thick free hand=blue, fit=(that)] {};
\node [thick free hand=green, fit=(this)] {};
\draw [thin arrow=blue, ->] (that-text.east) [bend left=45] to ++(.5,-.75) node [thin free hand=blue, anchor=north] {$c^2$};
\draw [thick arrow=magenta, <->] ([xshift=3pt]this-text.west) [out=180, in=180] to ([xshift=3pt]that-text.west);
\node [fit=(current bounding box), rounded corners=5pt, free hand, line width=1.5pt, draw=gray, postaction={draw=gray!10, line width=.75pt, opacity=.5}] {};
\end{tikzpicture}
\end{document}
See the answers to this question (of which Alain's is just one of many excellent ones) for a variety of approaches to creating that elusive 'hand-hewn' look with LaTeX. Not all of the answers use TikZ, but many do.
Note that Marc van Dongen's answer shows the pencil draw
approach applied to arcs. The issue with rounding the corners of rectangles is that the arcs wanted are very small and this creates various kinds of complexities which cause no end of trouble.