%% %% kleinbottle.sty %% %% Copyright (C) 2026 Benjamim Lima Neto %% %% This work may be distributed and/or modified under %% the conditions of the LaTeX Project Public License, %% either version 1.3c of this license or (at your option) %% any later version. %% %% The latest version of this license is available at: %% https://www.latex-project.org/lppl.txt %% %% This work has the LPPL maintenance status `maintained'. %% %% The Current Maintainer of this work is Benjamim Lima Neto. %% %% Contact information is provided in the accompanying %% README.md file. %% %% This work consists of the files: %% kleinbottle.sty %% kleinbottle.tex %% README.md %% %% and the derived file: %% kleinbottle.pdf %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{kleinbottle} [2026/11/26 v1.0 Klein bottle miniature] % -------------------------------------------------- % Required packages % -------------------------------------------------- \RequirePackage{xcolor} \RequirePackage{tikz} \RequirePackage{graphicx} % -------------------------------------------------- % User options and default values % -------------------------------------------------- \pgfkeys{ /kleinbottle/.is family, /kleinbottle, color/.store in=\kleinbottle@color, opacity/.store in=\kleinbottle@opacity, scale/.store in=\kleinbottle@scale, rotate/.store in=\kleinbottle@rotate, defaults/.style={ color=black, opacity=100, scale=1, rotate=0 } } % -------------------------------------------------- % Main command % -------------------------------------------------- \DeclareRobustCommand{\klein}[1][]{% \begingroup % Reset defaults and process user options \pgfkeys{/kleinbottle/.cd, defaults, #1}% % Validate opacity \pgfmathparse{ (\kleinbottle@opacity >= 0) * (\kleinbottle@opacity <= 100) }% \ifdim\pgfmathresult pt=0pt\relax \PackageError{kleinbottle} {Opacity must be between 0 and 100} {Use a numerical value between 0 and 100. The default value is 100.}% \def\kleinbottle@opacity{100}% \fi % Validate scale \pgfmathparse{\kleinbottle@scale > 0}% \ifdim\pgfmathresult pt=0pt\relax \PackageError{kleinbottle} {Scale must be positive} {Use a strictly positive numerical value. The default value is 1.}% \def\kleinbottle@scale{1}% \fi % Validate rotation \pgfmathparse{ (\kleinbottle@rotate >= 0) * (\kleinbottle@rotate <= 360) }% \ifdim\pgfmathresult pt=0pt\relax \PackageError{kleinbottle} {Rotation must be between 0 and 360} {Use an angle between 0 and 360 degrees. The default value is 0.}% \def\kleinbottle@rotate{0}% \fi % Convert percentage to TikZ opacity \pgfmathsetmacro{\kleinbottle@alpha} {\kleinbottle@opacity/100}% % Compute proportional scaling factor \pgfmathsetmacro{\kleinbottle@factor} {\kleinbottle@scale}% % ------------------------------------------------ % Klein bottle illustration % ------------------------------------------------ \scalebox{\kleinbottle@factor}{% \begin{tikzpicture}[ baseline=-0.1ex, scale=0.14, rotate=\kleinbottle@rotate, color=\kleinbottle@color, opacity=\kleinbottle@alpha, line width=0.55pt, line cap=round, line join=round ] % 1. Left outer wall \draw (-0.75, 0.3) .. controls (-0.75, 1.0) and (-0.28, 1.35) .. (-0.28, 1.9) .. controls (-0.28, 2.55) and (0.95, 2.55) .. (0.95, 1.8) .. controls (0.95, 1.45) and (0.72, 1.25) .. (0.50, 1.05); % 2. Inner neck wall \draw (0.12, 1.55) .. controls (0.10, 1.70) and (0.10, 1.80) .. (0.10, 1.9) .. controls (0.10, 2.15) and (0.55, 2.15) .. (0.55, 1.8) .. controls (0.55, 1.60) and (0.45, 1.42) .. (0.32, 1.25); % 3. Right outer wall \draw (0.75, 0.3) .. controls (0.75, 0.65) and (0.65, 0.90) .. (0.50, 1.05); \draw (0.32, 1.25) .. controls (0.20, 1.38) and (0.14, 1.48) .. (0.12, 1.55); % 4. Internal tube \draw[ densely dashed, dash pattern=on 1.2pt off 1pt ] (0.50, 1.05) .. controls (0.28, 0.85) and (0.18, 0.35) .. (0.18, -0.35); \draw[ densely dashed, dash pattern=on 1.2pt off 1pt ] (0.32, 1.25) .. controls (0.02, 0.98) and (-0.18, 0.35) .. (-0.18, -0.35); % 5. Bottom base \draw (-0.75, 0.3) .. controls (-0.75, -0.25) and (-0.35, -0.35) .. (-0.18, -0.35); \draw (0.75, 0.3) .. controls (0.75, -0.25) and (0.35, -0.35) .. (0.18, -0.35); % 6. Bottom opening \draw (0, -0.35) ellipse (0.18 and 0.06); \end{tikzpicture}% }% \endgroup } \endinput