% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ggplot2-integration.R
\name{element_latex}
\alias{element_latex}
\title{A ggplot2 theme element for LaTeX text}
\usage{
element_latex(
  math_font = "",
  fontsize = NULL,
  lineheight = 1.2,
  max_width = 0,
  input_mode = c("mixed", "math"),
  render_mode = c("typeface", "path"),
  ...
)
}
\arguments{
\item{math_font}{Name of the math font to use (e.g., \code{"stix"}).
Use \code{""} (default) for Lete Sans Math, which pairs with R's
default sans-serif text font.
See \code{\link{available_math_fonts}} for loaded fonts.}

\item{fontsize}{Convenience alias for \code{size}; when supplied,
it is forwarded to \code{ggplot2::element_text()} as the text size
in points. If \code{NULL} (default), the theme's inherited size is
used.}

\item{lineheight}{Multi-line height multiplier (default 1.2), matching
\code{grid::gpar()} semantics.}

\item{max_width}{Numeric maximum width in big points for automatic
line wrapping.  Use \code{0} (default) for no wrapping.}

\item{input_mode}{How \code{tex} is interpreted before being parsed.
\code{"mixed"} (default) wraps the input in \code{\\text{...}} so the
string reads as ordinary text and \code{$...$} (or \code{\\(...\\)})
opens math mode, matching document-level LaTeX semantics. Useful for
labels that arrive from external sources mixing prose and math without
explicit \code{\\text{}} markers. \code{"math"} is the classic
MicroTeX behaviour --- the whole string is treated as math, so unwrapped
prose renders as spaced math italics. The default can be changed globally via
\code{\link{latex_options}(input_mode = "math")}. See \code{\link{latex_wrap}}
for details on the wrapping process.}

\item{render_mode}{Character string: \code{"typeface"} (default) renders
glyphs as native text using the math font, producing
selectable/accessible text in PDF and SVG output.
Bundled math fonts and any registered via \code{\link{load_math_font}}
are read directly from their OTF files --- no system-wide font
install is required.
Falls back to path mode automatically on devices that lack the
R \eqn{\geq} 4.3 glyph engine (e.g., the base \code{pdf()} device).
For selectable PDF output, prefer \code{\link[grDevices]{cairo_pdf}}.
\code{"path"} renders math symbols as filled vector paths (works on
all devices but text is not selectable in PDF/SVG).}

\item{...}{Additional arguments passed to \code{ggplot2::element_text()}
(e.g., \code{size}, \code{colour}, \code{hjust}).}
}
\value{
An S7 object of class \code{element_latex}, inheriting from
\code{ggplot2::element_text}.
}
\description{
Use this as a theme element for axis titles, axis labels, plot titles,
or any other text element in a ggplot2 theme. The text string is parsed
as LaTeX math and rendered via MicroTeX.
}
\details{
Dollar signs (\code{$...$}) in the label text are stripped automatically
so that both \code{"\\frac{a}{b}"} and \code{"$\\frac{a}{b}$"} work.

This element is an S7 subclass of \code{ggplot2::element_text}, so it
inherits all standard text properties (size, colour, hjust, etc.) from
the theme and supports \code{merge_element()} correctly.
}
\examples{
\donttest{
if (requireNamespace("ggplot2", quietly = TRUE)) {
  library(ggplot2)
  ggplot(mtcars, aes(wt, mpg)) + geom_point() +
    labs(x = "$\\\\beta_1 \\\\cdot x + \\\\beta_0$") +
    theme(axis.title.x = element_latex())
}
}
}
