hooks_rtl: Customize knitr Hooks for Right-to-Left (RTL) Text Formatting

View source: R/hooks_rtl.R

hooks_rtlR Documentation

Customize knitr Hooks for Right-to-Left (RTL) Text Formatting

Description

This function defines customized knitr hooks to handle RTL (right-to-left) text formatting for languages like Persian and Arabic for Sweave. It allows you to modify the appearance of output, messages, warnings, and errors when producing RTL documents.

Usage

hooks_rtl(fontcolor = "black", backcolor = "gray")

Arguments

fontcolor

Font color for inline output. Default is "black".

backcolor

Background color for inline output. Default is "gray".

Value

The function returns a list of customized knit_hooks that handle RTL text formatting. It modifies the output, messages, warnings, errors, inline expressions, and source code to include appropriate commands for RTL languages.

When 'echo=FALSE' you need to use 'rtl=TRUE' in order to get the output appropriately.

References

Xie, Y. (2014). Dynamic Documents with R and knitr. Chapman & Hall/CRC. ISBN: 978-1482203530.

See Also

Use markdown_rtl to enable RTL formatting for Markdown documents.

Examples

# Define custom RTL hooks
rtl_hooks <- hooks_rtl()

# Apply custom RTL hooks to `knit_hooks`
knitr::knit_hooks$set(rtl_hooks)

# After setting the hooks, knit your document as usual to produce RTL formatting.


RTLknitr documentation built on Nov. 21, 2025, 5:06 p.m.