| 1 |
% !TeX root = ../easyfloats.tex |
| 2 |
|
| 3 |
% Copyright © 2020 E. Zöllner |
| 4 |
% Alternatively to the terms of the LPPL, at your choice, |
| 5 |
% you can redistribute and/or modify this file under the |
| 6 |
% terms of the Do What The Fuck You Want To Public License, Version 2, |
| 7 |
% as published by Sam Hocevar. See http://www.wtfpl.net/about/. |
| 8 |
|
| 9 |
% Redefines \cmd so that it can be used in a pdf string, |
| 10 |
% e.g. in \section{...}. |
| 11 |
% Please note that additionally to the restrictions |
| 12 |
% named in the ltxdoc documentation you cannot use \cmd{\ }. |
| 13 |
% That is a bug in ltxdoc and unrelated to pdf strings. |
| 14 |
% |
| 15 |
% This must be loaded last, after all other modifications |
| 16 |
% to the \cmd macro. |
| 17 |
|
| 18 |
\let\PdfstringOriginalCmd=\cmd |
| 19 |
\renewcommand{\cmd}[1]{% |
| 20 |
\texorpdfstring |
| 21 |
{\PdfstringOriginalCmd{#1}} |
| 22 |
{\expandafter\PdfstringCmd\string#1\relax}% |
| 23 |
} |
| 24 |
|
| 25 |
\def\PdfstringCmd#1#2#3\relax{% |
| 26 |
\textbackslash |
| 27 |
\ifnum\noexpand`\\=\noexpand`#2 |
| 28 |
\textbackslash |
| 29 |
\else\ifnum\noexpand`\%=\noexpand`#2 |
| 30 |
\%% |
| 31 |
\else |
| 32 |
#2% |
| 33 |
\fi\fi |
| 34 |
#3% |
| 35 |
} |