
# kleinbottle

A tiny LaTeX package for drawing customizable Klein bottle miniatures.

**Author:** Benjamim Lima Neto  
**Version:** 1.01  
**Release date:** 2026-11-30  
**License:** LPPL 1.3c or later

## Overview

The `kleinbottle` package provides a customizable vector
illustration of the Klein bottle using TikZ.

Through a single command, users can insert miniature
representations of the Klein bottle into LaTeX documents
and customize their color, opacity, scale, rotation,
and position.

## Features

- Custom colors and color mixing.
- Uniform percentage-based opacity.
- Proportional scaling.
- Counterclockwise rotation.
- Horizontal and vertical positioning.
- Positive, negative, and fractional displacements.
- Independent customization of each miniature.
- Support for consecutive inline miniatures.
- Vector graphics without external image files.

## Installation

If the package is installed in your TeX distribution,
simply load it in the preamble:

```latex
\usepackage{kleinbottle}
```

For manual installation, place `kleinbottle.sty`
in the same directory as your main LaTeX document.

## Usage

The default miniature is produced by:

```latex
\klein
```

The complete syntax is:

```latex
\klein[
    color=black,
    opacity=100,
    scale=1,
    rotate=0,
    left=0,
    right=0,
    up=0,
    down=0
]
```

All options are optional and may be specified
in any order.

| Option  | Default | Accepted values |
|---------|---------|-----------------|
| color   | black   | Valid xcolor expressions |
| opacity | 100     | Numbers from 0 to 100 |
| scale   | 1       | Positive numbers |
| rotate  | 0       | Degrees from 0 to 360 |
| left    | 0       | Signed displacement in cm |
| right   | 0       | Signed displacement in cm |
| up      | 0       | Signed displacement in cm |
| down    | 0       | Signed displacement in cm |

Numerical values should be specified without units,
using a decimal point rather than a decimal comma.

Numerical values are subject to the precision
and dimensional limits of PGF and TeX.

## Positioning

The positioning keys introduced in version 1.01
allow precise control over the placement of the miniature.

```latex
\klein[up=0.5]
\klein[right=1]
\klein[left=-0.5]
\klein[rotate=180, up=0.3]
```

All displacements are expressed in centimeters
and are independent of scaling and rotation.

Opposite displacements are combined algebraically:

- Horizontal displacement: right - left.
- Vertical displacement: up - down.

Horizontal displacement preserves the original
horizontal advance of the miniature. Consequently,
large displacements may cause overlapping with
surrounding content.

Vertical displacement may affect line height and depth.

## Minimal Working Example

```latex
\documentclass{article}
\usepackage{kleinbottle}

\begin{document}

The Klein bottle \klein\ is a non-orientable surface.

Two consecutive Klein bottles: \klein\ \klein.

\begin{center}

    \klein[color=blue, scale=5]
    \qquad
    \klein[color=red, opacity=50, scale=3, rotate=45]

\end{center}

\begin{center}

    \klein[color=pink, opacity=80,
           scale=3, rotate=180, up=0.5]

\end{center}

\end{document}
```

## Dependencies

The package automatically loads:

- TikZ/PGF
- xcolor
- graphicx

No external image files or special fonts are required.

## Compatibility

Version 1.01 has been tested with:

- pdfLaTeX
- XeLaTeX
- LuaLaTeX
- Beamer

The existing customization interface from version 1.0
remains supported.

## Documentation

The complete user manual is available in
[kleinbottle.pdf](kleinbottle.pdf).

The LaTeX source of the documentation is provided
in `kleinbottle.tex`.

## CTAN

https://ctan.org/pkg/kleinbottle

## Maintenance

The author and current maintainer of this package
is Benjamim Lima Neto.

Bug reports and suggestions are welcome through
the Issues section of this GitHub repository.

## License

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.

This work consists of the files:

- kleinbottle.sty
- kleinbottle.tex
- README.md

and the derived file:

- kleinbottle.pdf

The accompanying LICENSE file contains the official
LPPL license text.

## Version History

### Version 1.01 — November 30, 2026

- Fixed unintended paragraph breaks.
- Improved consecutive inline placement.
- Fixed opacity accumulation at overlapping strokes.
- Introduced four signed positioning keys.
- Preserved the original Klein bottle illustration.
- Preserved the existing customization interface.
- Updated the documentation and examples.

### Version 1.0 — November 26, 2026

- Initial release.
- Introduced the `\klein` command.
- Added color, opacity, scale, and rotation options.
