| 1 |
texdimens |
| 2 |
========= |
| 3 |
|
| 4 |
## Copyright and License |
| 5 |
|
| 6 |
Copyright (c) 2021 Jean-François Burnol |
| 7 |
|
| 8 |
This file is part of the texdimens package distributed (see file |
| 9 |
LICENSE.md) under the [LPPL 1.3c](https://ctan.org/license/lppl1.3c). |
| 10 |
|
| 11 |
Release: [1.1 2021/11/17](https://github.com/jfbu/texdimens/compare/1.0...1.1#files_bucket) |
| 12 |
|
| 13 |
## Usage |
| 14 |
|
| 15 |
Utilities and documentation related to TeX dimensional units, usable: |
| 16 |
|
| 17 |
- with Plain TeX: `\input texdimens` |
| 18 |
|
| 19 |
- with LaTeX: `\usepackage{texdimens}` |
| 20 |
|
| 21 |
Development and issue tracking: https://github.com/jfbu/texdimens |
| 22 |
|
| 23 |
## Aim of this package |
| 24 |
|
| 25 |
The aim of this package is to provide facilities to express dimensions |
| 26 |
(or dimension expressions evaluated by `\dimexpr`) using the various |
| 27 |
available TeX units, to the extent possible. |
| 28 |
|
| 29 |
## Macros of this package (summary) |
| 30 |
|
| 31 |
This package provides expandable macros: |
| 32 |
|
| 33 |
- `\texdimenUU` with `UU` standing for one of `pt`, `bp`, `cm`, `mm`, |
| 34 |
`in`, `pc`, `cc`, `nc`, `dd` and `nd`, |
| 35 |
- `\texdimenUUup` and `\texdimenUUdown` with `UU` as above except `pt`, |
| 36 |
- `\texdimenbothincm` and relatives, |
| 37 |
- `\texdimenbothbpmm` and relatives, |
| 38 |
- `\texdimenwithunit`. |
| 39 |
|
| 40 |
`\texdimenbp` takes on input some dimension or dimension expression and |
| 41 |
produces on output a decimal `D` such that `D bp` is guaranteed to be |
| 42 |
the same dimension as the input, *if* it admits any representation as `E bp`; |
| 43 |
else it will be either the closest match from above or from |
| 44 |
below. For this unit, as well as for `nd` and `dd` the difference is at |
| 45 |
most `1sp`. For other units (not `pt` of course) the distance will |
| 46 |
usually be larger than `1sp` and one does not know if the approximant |
| 47 |
from the other direction would have been better or worst. |
| 48 |
|
| 49 |
The variants `\texdimenbpup` and `\texdimenbpdown` expand slightly less |
| 50 |
fast than `\texdimenbp` but they allow to choose the direction of |
| 51 |
approximation (in absolute value). |
| 52 |
|
| 53 |
The macros associated to the other units have |
| 54 |
the same descriptions. |
| 55 |
|
| 56 |
`\texdimenbothincm`, respectively `\texdimenbothbpmm`, find the largest |
| 57 |
(in absolute value) dimension not exceeding the input and exactly |
| 58 |
representable both with the `in` and `cm` units, respectively exactly |
| 59 |
representable both with the `bp` and `mm` units. |
| 60 |
|
| 61 |
`\texdimenwithunit{<dimen1>}{<dimen2>}` produces a decimal `D` such that |
| 62 |
`D \dimexpr dimen2\relax` is parsed by TeX into the same dimension as |
| 63 |
`dimen1` if this is at all possible. If `dimen2<1pt` all TeX dimensions |
| 64 |
`dimen1` are attainable. If `dimen2>1pt` not all `dimen1` are |
| 65 |
attainable. If not attainable, the decimal `D` will ensure a closest |
| 66 |
match from below or from above but one does not know if the |
| 67 |
approximation from the other direction is better or worst. |
| 68 |
|
| 69 |
In a sense, this macro divides `<dimen1>` by `<dimen2>`, see additional |
| 70 |
details in the complete macro description. |
| 71 |
|
| 72 |
## Acknowledgements |
| 73 |
|
| 74 |
Thanks to Denis Bitouzé for raising an |
| 75 |
[issue](https://github.com/latex3/latex3/issues/953) |
| 76 |
on the LaTeX3 tracker which became the initial stimulus for this package. |
| 77 |
|
| 78 |
Thanks to Ruixi Zhang for reviving the above linked-to thread and |
| 79 |
opening up on the package issue tracker the |
| 80 |
[issue #2](https://github.com/jfbu/texdimens/issues/2) asking to add |
| 81 |
handling of the `ex` and `em` cases. This was done at release `0.99` via |
| 82 |
the addition of `\texdimenwithunit`. |
| 83 |
|
| 84 |
Renewed thanks to Ruixi Zhang for analyzing at |
| 85 |
[issue #10](https://github.com/jfbu/texdimens/issues/10) what is at |
| 86 |
stake into finding dimensions exactly representable both in the `bp` and |
| 87 |
`mm` units. Macros `\texdimenbothbpmm` and `\texdimenbothmmbp` now |
| 88 |
address this (release `1.0`). |
| 89 |
|
| 90 |
<!-- |
| 91 |
--> |