Template:Roman
| This template uses Lua: |
| Related pages |
|---|
This template converts Arabic numerals (that is, 1, 2, 3, etc.) into Roman numerals (I, II, III etc.). It currently works for any whole number between 1 and 4999999.
Usage[edit]
{{Roman|number|message}}
This template implements a version of the functionality provided by the HTML <pre> tag.
Usage[edit]
This template supports two parameters
|width= The width of the pre "box"
|space= The way white space is handled in the pre "box"
| Markup | Renders as |
|---|---|
{{Pre|
This Pre-format
can look
like this.
}}
|
Template loop detected: Template:Pre |
Main differences include:
- It wraps text that overflows the page.
- It allows mid-line-breaks (but not always consistently).
Main limitations include:
- If the text is a single long word, it won't be wrapped and will still break out to the right hand of the page.
- HTML and wikimarkup aren't disabled as in
<pre>...</pre>and are rendered as usual (thus if a parameter contains any wikimarkup, enclose it in<nowiki>...</nowiki>); however, multiple spaces are preserved.
As with <pre> and <code>, {{pre}} displays text in the font specified as the monospace font in the user's browser options, or specified in the user's CSS pages.
Example[edit]
Markup
{{Pre|
'''First line, markup working:''' and HTML comment <!--HIDDEN--> hidden.
'''Second line, long text wrapping:''' all work and no play make jack a dull boy all work and no play make jack a dull boy all work and no play make jack a dull boy all work and no play make jack a dull boy all work and no play make jack a dull boy.
'''Third line with raw | pipe is handled''', but the space before the pipe is lost. Up to raw 20 pipes are handled, else use <nowiki>{{!}}</nowiki> and {{!}} it's {{!}} OK.
'''Fourth line, multiple spaces preserved''' unlike in HTML and wikitext.
'''Fifth line, following the previous one'''.
'''Last line''' preceded by two blank lines in markup and in display.
}}
- Result
Template loop detected: Template:Pre
See also[edit]
- {{pre2}}, a template with similar functionality but induces optional line wrap and optional scroll bars.
<syntaxhighlight><pre>
Replace number with the number you would like to be converted to Roman numerals. For numbers higher than 4999999 the template outputs "N/A". This can be changed by replacing message with your preferred text.
An overline, representing multiplication by 1000, is used to extend the upper range of the function.
See Roman numerals for further information.
Fraction support[edit]
The template can accept parsing decimals, fractions, and arithmetic expressions. This is not enabled by default. To enable this, supply |fraction=yes, i.e. {{Roman|105.5|fraction=yes}} or {{Roman|105.5|too big|fraction=yes}}.
Roman numeral output for fractional values uses these symbols:
- S = ½
- : = 1/6
- • = 1/12
- Є = 1/24
- ƧƧ = 1/36
- Ɔ = 1/48
- Ƨ = 1/72
Ƨ= 1/144- ℈ = 1/288
- » = 1/1728
- N = 0
Examples[edit]
| Arabic Numerals | Template Call | Roman Numerals |
|---|---|---|
| 0 | {{Roman|0}} | N |
| 1 | {{Roman|1}} | I |
| 2 | {{Roman|2}} | II |
| 49 | {{Roman|49}} | XLIX |
| 50 | {{Roman|50}} | L |
| 51 | {{Roman|51}} | LI |
| 1024 | {{Roman|1024}} | MXXIV |
| 4999 | {{Roman|4999}} | IVCMXCIX |
| 5000 | {{Roman|5000}} | V |
| 5001 | {{Roman|5001}} | VI |
| 69105 | {{Roman|69105}} | LXIXCV |
| 1048576 | {{Roman|1048576}} | MXLVMMMDLXXVI |
| 7654321 | {{Roman|7654321}} | N/A |
| 7654321 | {{Roman|7654321|too high}} | too high |
If the number provided is negative, the template will output an error message. If the first parameter provided cannot be interpreted as a number, the template will also output an error message. If no arguments are given, the template produces no output.
Examples:
{{Roman}}:{{Roman|}}:
Decimal, fractional, and arithmetic examples[edit]
| Value | Template Call | Roman Numerals |
|---|---|---|
| 0.0005 | {{Roman|0.0005|fraction=yes}} | » |
| 20.002 | {{Roman|20.002|fraction=yes}} | XX»»» |
| 110.003472 | {{Roman|110.003472|fraction=yes}} | CX℈ |
| 3+4.007 | {{Roman|3+4.007|fraction=yes}} | VII |
| 1-0.9861 | {{Roman|1-0.9861|fraction=yes}} | Ƨ |
| 4.6*2.5 | {{Roman|4.6*2.5|fraction=yes}} | XIS |
| 1/3 | {{Roman|1/3|fraction=yes}} | :: |
| 9999/10000 | {{Roman|9999/10000|fraction=yes}} | S:•:ЄƧƧ |
| 100+5.5 | {{Roman|100+5.5|fraction=yes}} | CVS |
TemplateData[edit]
TemplateData for Roman
Convert numbers to Roman numerals.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Number | 1 | The number to be converted to Roman numerals. If the parameter passed cannot be interpreted as a numerical value, no output is generated.
| Number | optional |
| Message | 2 | Message to display for numbers that are too big to be displayed in Roman numerals. (The largest number supported is 4999999.)
| String | optional |
See also[edit]
| The above documentation is transcluded from Template:Roman/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |