Skip to contents

A set of CSS declarations, for use as a named argument to markdown_style. Argument names are the CSS property names with underscores in place of hyphens, so font_size sets font-size.

Usage

md_style(...)

Arguments

...

Named declarations.

Value

An object of class gridmicrotex_md_style.

Details

Lengths accept three forms: a bare number is rem, a multiple of the body font size (font_size = 2.5); a string is whatever CSS says it is ("2.5em", "12pt", "150%"); and a unit is absolute.

These are the supported properties, and where each one has an effect. Inline means it also works on a <span> and in markdown_grob, which has no block layout; block means it needs markdown_box_grob.

propertyscopenotes
colorinline + block
font_sizeinline + block
font_familyinline + block
font_weightinline + blockprose blocks only, see below
font_styleinline + blockprose blocks only, see below
text_decorationinline + blockunderline, overline, line-through
backgroundinline + blocka fill behind the text
borderinlinea frame; the inset is fixed
border_styleinlineonly double
border_radiusinlinerounds the frame
box_shadowinline
visibilityinlinehidden keeps the space
vertical_aligninlinesuper, sub, or a length
transforminlinerotate(), scale(), scaleX(-1)
line_heightblockunitless, as gpar() wants it
margin_top, margin_bottomblockmargins do not collapse
margin_left, margin_rightblock
padding_left, padding_rightblock
padding_top, padding_bottomblock
margin, paddingblockthe CSS shorthand: one to four lengths, in CSS's order
text_alignblockleft, center, right
border_leftblockthe blockquote bar
border_topblockthe hr rule
border_bottomtra rule under each table row
border_colortablecolour of the table's rules
table_layouttablefixed divides the width between the columns so a wide table wraps
heightblockthe band an hr sits in
bulletulraw LaTeX for the marker glyph
marker_gapul, olmarker to text

font_size also accepts CSS's keywords — xx-small through xx-large, plus smaller and larger — taken from the \tiny..\Huge ladder MicroTeX implements.

The body rule styles the box itself. On any other tag, background, border, border_radius, padding and margin apply to that block. On body they apply to the whole markdown_box_grob — its fill, its frame, its corner radius, and the space inside and outside it. That is the only way to give a element_markdown title a background, since the theme element takes no box arguments of its own:

body { background: grey95; padding: 8px;
        border: 1px solid grey60; border-radius: 4px }

An explicit box_gp, padding, margin or r argument to markdown_box_grob() wins over the rule, the way an inline style wins in CSS.

Anything else is an error — unlike a pasted stylesheet, where an unknown property is ignored the way a browser ignores it.

One limitation worth knowing. font_weight and font_style apply to blocks whose content is prose — paragraphs, headings, list items, block quotes, table cells and <div>s. They do not apply to pre or an image's alt text, which build their own LaTeX and impose their own font handling. This is a MicroTeX constraint rather than a choice: \text{} resets the font style, so emphasis has to be decided when the content is generated, not wrapped around it afterwards.

What cannot be styled at all. There is no small-caps (\textsc is not a MicroTeX command), no font-variant-numeric, no right-to-left or bidirectional text, and no padding inside an inline border — MicroTeX has no \fboxsep, so that inset is fixed.

Examples

md_style(color = "steelblue", font_size = 2.5, margin_top = 1.2)
#> <md_style>
#>   color            steelblue
#>   font-size        2.5
#>   margin-top       1.2