imagepdfpackager-markdowntitle

How to install `titling` package via RStudio?


I need to knit an rmarkdown document in pdf format, which would contain an image on top of the title. Reading on it at https://bookdown.org/yihui/rmarkdown-cookbook/latex-logo.html and some other answers here on how to do this, it seems I need to use the titling package ,that I do not seem to have installed, and which i tried to install following the instructions from

https://bookdown.org/yihui/rmarkdown-cookbook/install-latex-pkgs.html

However, i get the following error:

> tinytex::parse_install("Filename.log")
tlmgr search --file --global "/titling.sty"
tlmgr install titling
Unable to download the checksum of the remote TeX Live database,
but found a local copy, so using that.

You may want to try specifying an explicit or different CTAN mirror,
or maybe you need to specify proxy information if you're behind a firewall;
see the information and examples for the -repository option at
https://tug.org/texlive/doc/install-tl.html
(and in the output of install-tl --help).

tlmgr.pl: package repository http://ftp.math.purdue.edu/mirrors/ctan.org/systems/texlive/tlnet (not verified: unknown)
[1/1, ??:??/??:??] install: titling [3k]
TLPDB::_install_data: downloading did not succeed (download_file failed) for http://ftp.math.purdue.edu/mirrors/ctan.org/systems/texlive/tlnet/archive/titling.tar.xz
tlmgr.pl: package log updated: C:/Users/Owner/AppData/Roaming/TinyTeX/texmf-var/web2c/tlmgr.log

I also tried to download the package from CTAN and install it via RStudio using Tools > Install Packages, but also got error due to lack of DESCRIPTION file:

install.packages("~/titling.zip", repos = NULL, type = "win.binary")
Installing package into ‘C:/Users/Owner/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
  cannot open compressed file 'titling/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection

Any help appreciated, thanks


Solution

  • Your second method does not work because base::install.packages() and RStudio's Tools -> Install Packages are only appropriate for R packages (usually via CRAN), not LaTeX packages.

    Your first method should be working - I believe there is a problem with the mirror you are trying to download the package from. See this related github issue. You can choose an appropriate mirror from the links in that post or you could first try this:

    tinytex::tlmgr(
      c('option', 'repository', 'http://ctan.math.washington.edu/tex-archive/systems/texlive/tlnet')
    )
    

    Try a few mirrors by inserting their links, you can see your choices here. Make sure to try mirrors that are appropriate to the country that you are in.

    After choosing mirrors try running your original code to download the package via TinyTex and see what happens.