| 1 |
% Copyright (C) 2011 by Yossi Gil [email protected] |
| 2 |
% --------------------------------------------------------------------------- |
| 3 |
% This work may be distributed and/or modified under the conditions of the |
| 4 |
% LaTeX Project Public License (LPPL), either version 1.3 of this license or (at your |
| 5 |
% option) any later version. The latest version of this license is in |
| 6 |
% http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all |
| 7 |
% distributions of LaTeX version 2005/12/01 or later. |
| 8 |
% |
| 9 |
% This work has the LPPL maintenance status `maintained'. |
| 10 |
% |
| 11 |
% The Current Maintainer of this work is Yossi Gil |
| 12 |
% |
| 13 |
% This work consists of the files unisugar.tex and unisugar.sty and the derived |
| 14 |
% file unisugar.pdf |
| 15 |
\NeedsTeXFormat{LaTeX2e} |
| 16 |
|
| 17 |
\newcommand\date@unisugar{2011/05/07} |
| 18 |
\newcommand\version@unisugar{V 0.92} |
| 19 |
\newcommand\author@unisugar{Yossi Gil} |
| 20 |
\newcommand\mail@unisugar{[email protected]} |
| 21 |
\newcommand\signature@unisugar{% |
| 22 |
unisugar \version@unisugar{} by |
| 23 |
\author@unisugar{} \mail@unisugar |
| 24 |
} |
| 25 |
|
| 26 |
\ProvidesPackage{unisugar}[\date@unisugar{} \signature@unisugar: |
| 27 |
Selected Unicode characters (e.g., ⌘, ␣, •, ⏎, ¶, and §) |
| 28 |
employed in some very common LaTeX commands. |
| 29 |
] |
| 30 |
|
| 31 |
\PackageInfo{unisugar}{This is unisugar, \signature@unisugar} |
| 32 |
|
| 33 |
\RequirePackage{ifxetex} |
| 34 |
\typeout{This is the unisugar package} |
| 35 |
\providecommand\discardNextChar[1]{} |
| 36 |
|
| 37 |
\providecommand*{\toEolnCommand}[2]{% |
| 38 |
\newcommand*{#1}{% |
| 39 |
\begingroup |
| 40 |
\escapechar=`\\% |
| 41 |
\catcode\endlinechar=\active |
| 42 |
\csname\string#1\endcsname |
| 43 |
}% |
| 44 |
\begingroup% |
| 45 |
\escapechar=`\\% |
| 46 |
\lccode`\~=\endlinechar |
| 47 |
\lowercase{% |
| 48 |
\expandafter\endgroup |
| 49 |
\expandafter\def\csname\string#1\endcsname##1~% |
| 50 |
}{\endgroup#2\space}% |
| 51 |
} |
| 52 |
|
| 53 |
\toEolnCommand\toEolnSection{\section{#1}} |
| 54 |
\toEolnCommand\toEolnSubsection{\subsection{#1}} |
| 55 |
\toEolnCommand\toEolnSubsubsection{\subsubsection{#1}} |
| 56 |
\toEolnCommand\toEolnParagraph{\paragraph{#1}} |
| 57 |
\toEolnCommand\toEolnSubparagraph{\subparagraph{#1}} |
| 58 |
|
| 59 |
\ifxetex |
| 60 |
\relax |
| 61 |
\else |
| 62 |
\PackageWarning{You should be LaTeXing your file with "xelatex \jobname" |
| 63 |
to enjoy this package fully} |
| 64 |
\endinput |
| 65 |
\fi |
| 66 |
|
| 67 |
% ⌘: U+2318 PLACE OF INTEREST SIGN (also command key), is used as a direction |
| 68 |
% neutral escape character. Makes it possible to use the command key |
| 69 |
% character as a command prefix. Useful in particular with right-to-left texts, |
| 70 |
% in which the familiar, yet directionally non-neutral, backslash may be a bit confusing. |
| 71 |
\catcode"2318=11 |
| 72 |
\edef\⌘{⌘} |
| 73 |
\catcode"2318=0 |
| 74 |
|
| 75 |
% ␣: U+2423 OPEN BOX, a visual space is allowed as a legitimate character in |
| 76 |
% control sequences, whereby eliminating the need for ugly juxtaposing of words. |
| 77 |
\catcode"2423=11 |
| 78 |
\edef\␣{␣} |
| 79 |
|
| 80 |
|
| 81 |
% …: U+2026 HORIZONTAL ELLIPSIS, will serve as a sugar nickname for \ldots. |
| 82 |
⌘catcode"2026=⌘active |
| 83 |
⌘newcommand…{⌘ldots} |
| 84 |
|
| 85 |
% •: U+2022 BULLET (black small circle), a sugared alias for ⌘item. |
| 86 |
⌘catcode"2022=11 |
| 87 |
⌘edef⌘•{•} |
| 88 |
⌘catcode"2022=⌘active |
| 89 |
⌘newcommand•{⌘item} |
| 90 |
|
| 91 |
% ⏎: U+23CE RETURN SYMBOL, a sugared nickname for \\ |
| 92 |
⌘catcode"23CE=11 |
| 93 |
⌘edef\⏎{⏎} |
| 94 |
⌘catcode"23CE=⌘active |
| 95 |
⌘newcommand⏎{\\} |
| 96 |
|
| 97 |
% ⌖: U+2316 POSITION INDICATOR, is an alias for LaTeX's \label command. |
| 98 |
⌘catcode"2316=11 |
| 99 |
⌘edef\⌖{⌖} |
| 100 |
⌘catcode"2316=⌘active |
| 101 |
⌘newcommand⌖[1]{⌘label{#1}} |
| 102 |
|
| 103 |
% ☝: U+261D WHITE UP POINTING INDEX, is an alias LaTeX's \ref command. |
| 104 |
⌘catcode"261D=11 |
| 105 |
⌘edef\☝{☝} |
| 106 |
⌘catcode"261D=⌘active |
| 107 |
⌘newcommand☝[1]{⌘ref{#1}} |
| 108 |
|
| 109 |
% ¶: U+00B6 PILCROW SIGN, will serve as a sugar nickname for ⌘paragraph, using |
| 110 |
% the remainder of the line as the paragraph's title. Further, ¶¶, that is two |
| 111 |
% successive occurrences of the pilcrow sign, shall serve as a sugared nickname |
| 112 |
% for ⌘subparagraph, employing the remainder of the text on the current line as |
| 113 |
% the subparagraph's title. |
| 114 |
⌘catcode"B6=11 |
| 115 |
⌘edef\¶{¶} |
| 116 |
⌘catcode"B6=⌘active |
| 117 |
⌘newcommand¶{⌘paragraph␣sugar} |
| 118 |
|
| 119 |
\newcommand\paragraph␣sugar{% |
| 120 |
\@ifnextchar¶{% |
| 121 |
\expandafter |
| 122 |
\toEolnSubparagraph |
| 123 |
\discardNextChar |
| 124 |
}{% |
| 125 |
\toEolnParagraph |
| 126 |
}% |
| 127 |
} |
| 128 |
|
| 129 |
% §: U+00A7 SECTION SIGN, will serve as a sugar nickname for ⌘section, using |
| 130 |
% the remainder of the line as the section's title. Further, §§, that is two |
| 131 |
% successive occurrences of this Unicode code point, shall serve as a sugared |
| 132 |
% nickname for ⌘subsection, employing the remainder of the text on the current |
| 133 |
% line as the subsection's title. Even further, §§§, three successive |
| 134 |
% occurrences shall serve as a sugared nickname for ⌘subsubsection, employing |
| 135 |
% again, the remainder of text on the line as the subsubsection's title. |
| 136 |
% |
| 137 |
⌘catcode"A7=11 |
| 138 |
⌘edef\§{§} |
| 139 |
⌘catcode"A7=⌘active |
| 140 |
⌘newcommand§{⌘section␣sugar} |
| 141 |
⌘newcommand⌘section␣sugar{% |
| 142 |
\@ifnextchar§{% Two or more § were found. |
| 143 |
\expandafter |
| 144 |
\sub␣or␣subsub␣section |
| 145 |
\discardNextChar |
| 146 |
}{% Single § found. |
| 147 |
\toEolnSection |
| 148 |
}% |
| 149 |
} |
| 150 |
|
| 151 |
\newcommand*\sub␣or␣subsub␣section{% |
| 152 |
\@ifnextchar§{% |
| 153 |
\expandafter |
| 154 |
\toEolnSubsubsection |
| 155 |
\discardNextChar |
| 156 |
}{% |
| 157 |
\toEolnSubsection |
| 158 |
}% |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|