| 1 |
%% |
| 2 |
%% This is file `DPcircling.sty' |
| 3 |
%% (Last Update: 2020/04/15) |
| 4 |
%% Maintained on GitHub: |
| 5 |
%% https://github.com/domperor/DPcircling |
| 6 |
%% |
| 7 |
%% Copyright (c) 2020 Oura M. (domperor) |
| 8 |
%% Released under the MIT license |
| 9 |
%% https://opensource.org/licenses/mit-license.php |
| 10 |
%% |
| 11 |
|
| 12 |
\NeedsTeXFormat{LaTeX2e} |
| 13 |
\ProvidesPackage{DPcircling}[2020/04/15 v1.0 circling letters with circ/rect/jag/fan using TikZ] |
| 14 |
|
| 15 |
\RequirePackage{tikz} |
| 16 |
\RequirePackage{keyval} |
| 17 |
|
| 18 |
%%Setting up dimensions and boxes |
| 19 |
\newbox\DPcircling@box |
| 20 |
\newdimen\DPcircling@content@wd |
| 21 |
\newdimen\DPcircling@content@ht |
| 22 |
\newdimen\DPcircling@content@dp |
| 23 |
\newdimen\DPcircling@outline@wd@user |
| 24 |
\newdimen\DPcircling@outline@ht@user |
| 25 |
\newdimen\DPcircling@outline@wd@user@temporal |
| 26 |
\newdimen\DPcircling@outline@ht@user@temporal |
| 27 |
\newdimen\DPcircling@outline@halfwd |
| 28 |
\newdimen\DPcircling@outline@halfht |
| 29 |
\newdimen\DPcircling@depressingheight |
| 30 |
\newdimen\DPcircling@linewidth |
| 31 |
\newdimen\DPcircling@linewidth@default |
| 32 |
\newdimen\DPcircling@linewidth@temporal |
| 33 |
|
| 34 |
%%Linecolor |
| 35 |
%%default=black |
| 36 |
\def\DPcircling@linecolor@default{black} |
| 37 |
\def\DPcirclingLinecolor#1{\def\DPcircling@linecolor@default{#1}} |
| 38 |
|
| 39 |
\newif\ifDPcircling@LinecolorTemporalSet |
| 40 |
\DPcircling@LinecolorTemporalSetfalse |
| 41 |
\def\DPcirclingTemporalLinecolor#1{\DPcircling@LinecolorTemporalSettrue |
| 42 |
\def\DPcircling@linecolor@temporal{#1}} |
| 43 |
|
| 44 |
%%Linewidth |
| 45 |
%%default=1pt |
| 46 |
\DPcircling@linewidth@default=1pt |
| 47 |
\def\DPcirclingLinewidth#1{\DPcircling@linewidth@default=#1} |
| 48 |
|
| 49 |
\newif\ifDPcircling@LinewidthTemporalSet |
| 50 |
\DPcircling@LinewidthTemporalSetfalse |
| 51 |
\def\DPcirclingTemporalLinewidth#1{\DPcircling@LinewidthTemporalSettrue |
| 52 |
\DPcircling@linewidth@temporal=#1} |
| 53 |
|
| 54 |
%%Outline Width |
| 55 |
\newif\ifDPcircling@OutlineWidthSet |
| 56 |
\DPcircling@OutlineWidthSetfalse |
| 57 |
\def\DPcirclingOutlineWidth#1{\DPcircling@OutlineWidthSettrue |
| 58 |
\DPcircling@outline@wd@user=#1} |
| 59 |
|
| 60 |
\newif\ifDPcircling@OutlineWidthTemporalSet |
| 61 |
\DPcircling@OutlineWidthTemporalSetfalse |
| 62 |
\def\DPcirclingTemporalOutlineWidth#1{\DPcircling@OutlineWidthTemporalSettrue |
| 63 |
\DPcircling@outline@wd@user@temporal=#1} |
| 64 |
|
| 65 |
%%Outline Height |
| 66 |
\newif\ifDPcircling@OutlineHeightSet |
| 67 |
\DPcircling@OutlineHeightSetfalse |
| 68 |
\def\DPcirclingOutlineHeight#1{\DPcircling@OutlineHeightSettrue |
| 69 |
\DPcircling@outline@ht@user=#1} |
| 70 |
|
| 71 |
\newif\ifDPcircling@OutlineHeightTemporalSet |
| 72 |
\DPcircling@OutlineHeightTemporalSetfalse |
| 73 |
\def\DPcirclingTemporalOutlineHeight#1{\DPcircling@OutlineHeightTemporalSettrue |
| 74 |
\DPcircling@outline@ht@user@temporal=#1} |
| 75 |
|
| 76 |
%%Baseline Adjustment and else |
| 77 |
\def\DPcircling@common#1{% |
| 78 |
%%setting up content box |
| 79 |
\ifmmode |
| 80 |
\def\DPcircling@content{$#1$}% |
| 81 |
\else |
| 82 |
\def\DPcircling@content{#1}% |
| 83 |
\fi |
| 84 |
% |
| 85 |
\setbox\DPcircling@box\hbox{\DPcircling@content}% |
| 86 |
\DPcircling@content@wd=\wd\DPcircling@box |
| 87 |
\DPcircling@content@ht=\ht\DPcircling@box |
| 88 |
\DPcircling@content@dp=\dp\DPcircling@box |
| 89 |
%%outline width |
| 90 |
\DPcircling@outline@halfwd=\DPcircling@content@wd |
| 91 |
\ifDPcircling@OutlineWidthSet% |
| 92 |
\DPcircling@outline@halfwd=0.5\DPcircling@outline@wd@user |
| 93 |
\fi |
| 94 |
\ifDPcircling@OutlineWidthTemporalSet |
| 95 |
\DPcircling@outline@halfwd=0.5\DPcircling@outline@wd@user@temporal |
| 96 |
\fi |
| 97 |
%%outline height |
| 98 |
\DPcircling@outline@halfht=\DPcircling@content@ht |
| 99 |
\ifDPcircling@OutlineHeightSet |
| 100 |
\DPcircling@outline@halfht=0.5\DPcircling@outline@ht@user |
| 101 |
\fi |
| 102 |
\ifDPcircling@OutlineHeightTemporalSet |
| 103 |
\DPcircling@outline@halfht=0.5\DPcircling@outline@ht@user@temporal |
| 104 |
\fi |
| 105 |
%%line width |
| 106 |
\DPcircling@linewidth=\DPcircling@linewidth@default |
| 107 |
\ifDPcircling@LinewidthTemporalSet |
| 108 |
\DPcircling@linewidth=\DPcircling@linewidth@temporal |
| 109 |
\fi |
| 110 |
%%line color |
| 111 |
\let\DPcircling@linecolor\DPcircling@linecolor@default |
| 112 |
\ifDPcircling@LinecolorTemporalSet |
| 113 |
\let\DPcircling@linecolor\DPcircling@linecolor@temporal |
| 114 |
\fi |
| 115 |
%%baseline adjustment |
| 116 |
\DPcircling@depressingheight=\DPcircling@outline@halfht |
| 117 |
\advance\[email protected]\DPcircling@content@ht |
| 118 |
\advance\[email protected]\DPcircling@content@dp |
| 119 |
\advance\[email protected]\DPcircling@linewidth |
| 120 |
} |
| 121 |
|
| 122 |
%%Option Keys[line color=...,line width=...,width=...,height=...] |
| 123 |
\define@key{DPcirclingkey}{line color}{\DPcirclingTemporalLinecolor{#1}} |
| 124 |
\define@key{DPcirclingkey}{line width}{\DPcirclingTemporalLinewidth{#1}} |
| 125 |
\define@key{DPcirclingkey}{width}{\DPcirclingTemporalOutlineWidth{#1}} |
| 126 |
\define@key{DPcirclingkey}{height}{\DPcirclingTemporalOutlineHeight{#1}} |
| 127 |
|
| 128 |
%%DefaultChanger \DPcirclingDefault{line color=...,line width=...,width=...,height=...} |
| 129 |
\define@key{DPcirclingDefaultkey}{line color}{\DPcirclingLinecolor{#1}} |
| 130 |
\define@key{DPcirclingDefaultkey}{line width}{\DPcirclingLinewidth{#1}} |
| 131 |
\define@key{DPcirclingDefaultkey}{width}{\DPcirclingOutlineWidth{#1}} |
| 132 |
\define@key{DPcirclingDefaultkey}{height}{\DPcirclingOutlineHeight{#1}} |
| 133 |
|
| 134 |
\def\DPcirclingDefault#1{% |
| 135 |
\setkeys{DPcirclingDefaultkey}{#1}% |
| 136 |
} |
| 137 |
|
| 138 |
%%Circle \DPcircling (=\DPcirc/\DPcircle) |
| 139 |
%%Default width=max{2*(content width), 2em} |
| 140 |
%%Default height=2*(content height) |
| 141 |
\def\DPcircling{\@ifnextchar[\@DPcircling{\@DPcircling[]}} |
| 142 |
\let\DPcirc\DPcircling |
| 143 |
\let\DPcircle\DPcircling |
| 144 |
\def\@DPcircling[#1]#2{% |
| 145 |
\setkeys{DPcirclingkey}{#1}% |
| 146 |
\@@DPcircling{#2}% |
| 147 |
\DPcircling@LinecolorTemporalSetfalse% |
| 148 |
\DPcircling@LinewidthTemporalSetfalse% |
| 149 |
\DPcircling@OutlineWidthTemporalSetfalse% |
| 150 |
\DPcircling@OutlineHeightTemporalSetfalse% |
| 151 |
} |
| 152 |
|
| 153 |
\def\@@DPcircling#1{\thinspace\DPcircling@common{#1}% |
| 154 |
\ifDPcircling@OutlineWidthSet\relax\else |
| 155 |
\ifDPcircling@OutlineWidthTemporalSet\relax\else |
| 156 |
\ifdim\DPcircling@content@wd<1em% |
| 157 |
\DPcircling@outline@halfwd=1em% |
| 158 |
\fi\fi\fi |
| 159 |
\raisebox{-\DPcircling@depressingheight}{% |
| 160 |
\begin{tikzpicture}% |
| 161 |
\draw[line width=\DPcircling@linewidth,color=\DPcircling@linecolor](0,0) ellipse [x radius=\DPcircling@outline@halfwd,y radius=\DPcircling@outline@halfht]; |
| 162 |
\draw[anchor=center,inner sep=0pt,outer sep=0pt] (0,0) node {\DPcircling@content}; |
| 163 |
\end{tikzpicture}% |
| 164 |
}\thinspace |
| 165 |
} |
| 166 |
|
| 167 |
%%Rectangle \DPrectangle (=\DPrect) |
| 168 |
%%Default width=(content width)+2em |
| 169 |
%%Default height=2*(content height) |
| 170 |
\def\DPrectangle{\@ifnextchar[\@DPrectangle{\@DPrectangle[]}} |
| 171 |
\let\DPrect\DPrectangle |
| 172 |
\def\@DPrectangle[#1]#2{% |
| 173 |
\setkeys{DPcirclingkey}{#1}% |
| 174 |
\@@DPrectangle{#2}% |
| 175 |
\DPcircling@LinecolorTemporalSetfalse% |
| 176 |
\DPcircling@LinewidthTemporalSetfalse% |
| 177 |
\DPcircling@OutlineWidthTemporalSetfalse% |
| 178 |
\DPcircling@OutlineHeightTemporalSetfalse% |
| 179 |
} |
| 180 |
|
| 181 |
\def\@@DPrectangle#1{\thinspace\DPcircling@common{#1}% |
| 182 |
\ifDPcircling@OutlineWidthSet\relax\else |
| 183 |
\ifDPcircling@OutlineWidthTemporalSet\relax\else |
| 184 |
\divide\DPcircling@outline@halfwd by 2% |
| 185 |
\advance\DPcircling@outline@halfwd1em% |
| 186 |
\fi\fi |
| 187 |
\raisebox{-\DPcircling@depressingheight}{% |
| 188 |
\begin{tikzpicture}% |
| 189 |
\draw[line width=\DPcircling@linewidth,color=\DPcircling@linecolor](-\DPcircling@outline@halfwd,-\DPcircling@outline@halfht) rectangle (\DPcircling@outline@halfwd,\DPcircling@outline@halfht); |
| 190 |
\draw[anchor=center,inner sep=0pt,outer sep=0pt] (0,0) node {\DPcircling@content}; |
| 191 |
\end{tikzpicture}% |
| 192 |
}\thinspace |
| 193 |
} |
| 194 |
|
| 195 |
%%Jagged Rectangle \DPjagged |
| 196 |
%%Default width=(content width)+2em |
| 197 |
%%Default height=2*(content height) |
| 198 |
\def\DPjagged{\@ifnextchar[\@DPjagged{\@DPjagged[]}} |
| 199 |
\def\@DPjagged[#1]#2{% |
| 200 |
\setkeys{DPcirclingkey}{#1}% |
| 201 |
\@@DPjagged{#2}% |
| 202 |
\DPcircling@LinecolorTemporalSetfalse% |
| 203 |
\DPcircling@LinewidthTemporalSetfalse% |
| 204 |
\DPcircling@OutlineWidthTemporalSetfalse% |
| 205 |
\DPcircling@OutlineHeightTemporalSetfalse% |
| 206 |
} |
| 207 |
|
| 208 |
\def\@@DPjagged#1{\thinspace\DPcircling@common{#1}% |
| 209 |
\ifDPcircling@OutlineWidthSet\relax\else |
| 210 |
\ifDPcircling@OutlineWidthTemporalSet\relax\else |
| 211 |
\divide\DPcircling@outline@halfwd by 2% |
| 212 |
\advance\DPcircling@outline@halfwd1em% |
| 213 |
\fi\fi |
| 214 |
\raisebox{-\DPcircling@depressingheight}{% |
| 215 |
\begin{tikzpicture}[x=0.048786\DPcircling@outline@halfwd,y=0.08952\DPcircling@outline@halfht]% |
| 216 |
\draw[line width=\DPcircling@linewidth,color=\DPcircling@linecolor]% |
| 217 |
(19.4975,10.9931)-- |
| 218 |
(14.8938,8.5269)-- |
| 219 |
(10.405,10.1944)-- |
| 220 |
(6.245,7.6269)-- |
| 221 |
(2.21,10.2181)-- |
| 222 |
(-2.195,8.5781)-- |
| 223 |
(-6.235,11.1706)-- |
| 224 |
(-10.1737,8.6031)-- |
| 225 |
(-14.4662,10.2694)-- |
| 226 |
(-17.9112,7.8244)-- |
| 227 |
(-19.7962,7.0806)-- |
| 228 |
(-18.0462,4.8219)-- |
| 229 |
(-20.4975,3.1006)-- |
| 230 |
(-17.925,1.2831)-- |
| 231 |
(-19.5262,-1.2756)-- |
| 232 |
(-16.955,-3.1006)-- |
| 233 |
(-19.41,-5.2731)-- |
| 234 |
(-17.65,-7.8869)-- |
| 235 |
(-19.4987,-10.9931)-- |
| 236 |
(-14.8937,-8.5281)-- |
| 237 |
(-10.4037,-10.1956)-- |
| 238 |
(-6.245,-7.6269)-- |
| 239 |
(-2.21,-10.2194)-- |
| 240 |
(2.195,-8.5794)-- |
| 241 |
(6.2363,-11.1706)-- |
| 242 |
(10.175,-8.6044)-- |
| 243 |
(14.4663,-10.2706)-- |
| 244 |
(17.9113,-7.8256)-- |
| 245 |
(19.7963,-7.0819)-- |
| 246 |
(18.0463,-4.8231)-- |
| 247 |
(20.4975,-3.1019)-- |
| 248 |
(17.9263,-1.2769)-- |
| 249 |
(19.5263,1.2856)-- |
| 250 |
(16.955,3.1169)-- |
| 251 |
(19.4113,5.2831)-- |
| 252 |
(17.66,7.9494)-- |
| 253 |
(19.4975,10.9931)-- |
| 254 |
cycle; |
| 255 |
\draw[anchor=center,inner sep=0pt,outer sep=0pt] (0,0) node {\DPcircling@content}; |
| 256 |
\end{tikzpicture}% |
| 257 |
}\thinspace |
| 258 |
} |
| 259 |
|
| 260 |
\def\DPfanshape{\@ifnextchar[\@DPfanshape{\@DPfanshape[]}} |
| 261 |
\def\@DPfanshape[#1]#2{% |
| 262 |
\setkeys{DPcirclingkey}{#1}% |
| 263 |
\@@DPfanshape{#2}% |
| 264 |
\DPcircling@LinecolorTemporalSetfalse% |
| 265 |
\DPcircling@LinewidthTemporalSetfalse% |
| 266 |
\DPcircling@OutlineWidthTemporalSetfalse% |
| 267 |
\DPcircling@OutlineHeightTemporalSetfalse% |
| 268 |
} |
| 269 |
|
| 270 |
%%Fan-shape \DPfanshape |
| 271 |
%%Default width=(content width)+2em |
| 272 |
%%Default height=2*(content height) |
| 273 |
\def\@@DPfanshape#1{\thinspace\DPcircling@common{#1}% |
| 274 |
\ifDPcircling@OutlineWidthSet\relax\else |
| 275 |
\ifDPcircling@OutlineWidthTemporalSet\relax\else |
| 276 |
\divide\DPcircling@outline@halfwd by 2% |
| 277 |
\advance\DPcircling@outline@halfwd1em% |
| 278 |
\fi\fi |
| 279 |
\raisebox{-\DPcircling@depressingheight}{% |
| 280 |
\begin{tikzpicture}[x=0.0467650318\DPcircling@outline@halfwd,y=0.114731528\DPcircling@outline@halfht]% |
| 281 |
\draw[line width=\DPcircling@linewidth,color=\DPcircling@linecolor]% |
| 282 |
(14.9805,-8.716) .. |
| 283 |
controls (5.4925,-4.252) and (-5.4925,-4.252) .. |
| 284 |
(-14.9805,-8.716) -- |
| 285 |
(-21.3835,4.891) .. |
| 286 |
controls (-7.8405,11.264) and (7.8395,11.264) .. |
| 287 |
(21.3835,4.891) -- |
| 288 |
(14.9805,-8.716) -- |
| 289 |
cycle; |
| 290 |
\draw[anchor=center,inner sep=0pt,outer sep=0pt] (0,0) node {\DPcircling@content}; |
| 291 |
\end{tikzpicture}% |
| 292 |
}\thinspace |
| 293 |
} |
| 294 |
\endinput |
| 295 |
%% |
| 296 |
%% End of file `DPcircling.sty'. |