| 1 |
Custom Roles in LaTeX |
| 2 |
--------------------- |
| 3 |
|
| 4 |
* Role names and class arguments are converted to conform to the |
| 5 |
regular expression ``[a-z][-a-z0-9]*`` (letters are downcased, |
| 6 |
accents and similar decoration is stripped, non-conforming |
| 7 |
characters are replaced by a hyphen). |
| 8 |
|
| 9 |
Class arguments may contain numbers and hyphens, which need special |
| 10 |
treatment in LaTeX command names. |
| 11 |
|
| 12 |
.. role:: custom4 |
| 13 |
:class: large custom4 small_caps custom.role custom\role |
| 14 |
|
| 15 |
:custom4:`Text with role "custom4"` (but without styling by ``DUrole*`` |
| 16 |
macros). |
| 17 |
|
| 18 |
* With LaTeX, roles can be styled within the document using the `raw` |
| 19 |
directive. |
| 20 |
|
| 21 |
.. raw:: latex |
| 22 |
|
| 23 |
\newcommand{\DUrolelarge}[1]{{\large #1}} |
| 24 |
\makeatletter |
| 25 |
\@namedef{DUrolesmall-caps}{\textsc} |
| 26 |
\@namedef{DUrolecustom4}{\textbf} |
| 27 |
\makeatother |
| 28 |
|
| 29 |
:custom4:`inline text` in large, bold, small-caps. |
| 30 |
|
| 31 |
* Custom roles can be based on standard roles: |
| 32 |
|
| 33 |
.. role:: custom-emphasis(emphasis) |
| 34 |
|
| 35 |
This is a :custom-emphasis:`customized emphasis text role` |
| 36 |
|
| 37 |
.. role:: custom-literal(literal) |
| 38 |
|
| 39 |
This is a :custom-literal:`customized literal text role` |
| 40 |
|
| 41 |
.. role:: custom-strong(strong) |
| 42 |
|
| 43 |
This is a :custom-strong:`customized strong text role` |
| 44 |
|
| 45 |
.. role:: custom-subscript(subscript) |
| 46 |
|
| 47 |
This is a :custom-subscript:`customized subscript text role` |
| 48 |
|
| 49 |
.. role:: custom-superscript(superscript) |
| 50 |
|
| 51 |
This is a :custom-superscript:`customized superscript text role` |
| 52 |
|
| 53 |
.. role:: custom-title-reference(title-reference) |
| 54 |
|
| 55 |
This is a :custom-title-reference:`customized title-reference text role` |