## A.3 LaTeX

LaTeX is required only if you want to convert your book to PDF. You may see https://www.latex-project.org/get/ for more information about LaTeX and its installation, but we strongly recommend that you install the lightweight and cross-platform LaTeX distribution named TinyTeX and based on TeX Live. TinyTeX can be easily installed through the R package tinytex (which should be automatically installed when you install bookdown):

tinytex::install_tinytex()

With TinyTeX, you should never see error messages like this:

! LaTeX Error: File titling.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.

l.107 ^^M

pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted

The above error means you used a package that contains titling.sty, but it was not installed. LaTeX package names are often the same as the *.sty filenames, so in this case, you can try to install the titling package. If you use TinyTeX with R Markdown, missing LaTeX packages will be installed automatically, so you never need to worry about such problems.

LaTeX distributions and packages are also updated from time to time, and you may consider updating them especially when you run into LaTeX problems. You can find out the version of your LaTeX distribution by:

system('pdflatex --version')
##  pdfTeX 3.141592653-2.6-1.40.24 (TeX Live 2022)
##  kpathsea version 6.3.4
##  Copyright 2022 Han The Thanh (pdfTeX) et al.
##  There is NO warranty.  Redistribution of this software is
##  covered by the terms of both the pdfTeX copyright and
##  the Lesser GNU General Public License.
##  Compiled with xpdf version 4.03
tinytex::tlmgr_update()
tinytex::reinstall_tinytex()`