rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.88k stars 974 forks source link

Missing *.sty files when generating PDFs #359

Closed natecobb closed 9 years ago

natecobb commented 9 years ago

Running rmarkdown out of RStudio 0.98.1091 on Ubuntu I am getting errors trying to generate PDFs. These started cropping up as we sequentially upgraded the server over the past 6 months or so.

Trying to generate the default .rmd template gives me a missing "titling.sty" file:

/usr/lib/rstudio-server/bin/pandoc/pandoc Preview-1e791624af74.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Preview-1e791624af74.pdf --template /home/natecobb/ShinyApps/tempdeleteme/packrat/lib/x86_64-pc-linux-gnu/3.1.2/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in' 
output file: Preview-1e791624af74.knit.md

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

Trying to generate a tufte handout gives me a similar error:

/usr/lib/rstudio-server/bin/pandoc/pandoc Preview-1e795f314859.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Preview-1e795f314859.pdf --template /home/natecobb/ShinyApps/tempdeleteme/packrat/lib/x86_64-pc-linux-gnu/3.1.2/rmarkdown/rmarkdown/templates/tufte_handout/resources/tufte-handout.tex --highlight-style pygments --latex-engine pdflatex 
output file: Preview-1e795f314859.knit.md

! LaTeX Error: File `tufte-handout.cls' not found.

I'm not sure where these files should be found, within RMarkdown or with RStudio/pandoc?

jjallaire commented 9 years ago

I think you need to install some additional LaTeX packages: texlive-latex-extra for titling.sty and texlive-pictures for the tufte-handout class

larsvilhuber commented 9 years ago

On openSUSE, this is in texlive-titling and texlive-tufte-latex (using obs://build.opensuse.org/Publishing)

jjallaire commented 9 years ago

These files need to be provided by your system LaTeX distribution. It's likely that as part of your upgrading your installation got pruned or otherwise modified. Installing the correct LaTeX packages should resolve the issue.

On Tue, Jan 20, 2015 at 4:06 PM, Nathan Cobb notifications@github.com wrote:

Running rmarkdown out of RStudio 0.98.1091 on Ubuntu I am getting errors trying to generate PDFs. These started cropping up as we sequentially upgraded the server over the past 6 months or so.

Trying to generate the default .rmd template gives me a missing "titling.sty" file:

/usr/lib/rstudio-server/bin/pandoc/pandoc Preview-1e791624af74.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Preview-1e791624af74.pdf --template /home/natecobb/ShinyApps/tempdeleteme/packrat/lib/x86_64-pc-linux-gnu/3.1.2/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in' output file: Preview-1e791624af74.knit.md

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

Trying to generate a tufte handout gives me a similar error:

/usr/lib/rstudio-server/bin/pandoc/pandoc Preview-1e795f314859.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Preview-1e795f314859.pdf --template /home/natecobb/ShinyApps/tempdeleteme/packrat/lib/x86_64-pc-linux-gnu/3.1.2/rmarkdown/rmarkdown/templates/tufte_handout/resources/tufte-handout.tex --highlight-style pygments --latex-engine pdflatex output file: Preview-1e795f314859.knit.md

! LaTeX Error: File `tufte-handout.cls' not found.

I'm not sure where these files should be found, within RMarkdown or with RStudio/pandoc?

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/359.

natecobb commented 9 years ago

Installing texlive-extras seemed to do the trick.

englianhu commented 9 years ago

Any solution for Centos7. http://bertelsen.ca/texlive-for-rmarkdown-on-ubuntu/

$sudo yum -y install texlive-extras
Loaded plugins: fastestmirror, langpacks
base                                                     | 3.6 kB     00:00
epel/x86_64/metalink                                     |  25 kB     00:00
epel                                                     | 4.3 kB     00:00
http://ftp.nluug.nl/pub/os/Linux/distr/fedora-epel/7/x86_64/repodata/repomd.xml: [Errno -1] repomd.xml does not match metalink for epel
Trying other mirror.
epel                                                     | 4.3 kB     00:00
extras                                                   | 3.4 kB     00:00
updates                                                  | 3.4 kB     00:00
epel/x86_64/updateinfo         FAILED
http://ftp.nluug.nl/pub/os/Linux/distr/fedora-epel/7/x86_64/repodata/b394fc8aa99a5721ac035c79baf15195be6e4b1808058d5b202d95bf882e99c8-updateinfo.xml.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
(1/2): epel/x86_64/updateinfo                              | 369 kB   00:00
(2/2): epel/x86_64/primary_db                              | 3.5 MB   00:03
Determining fastest mirrors
 * base: mirror.nl.leaseweb.net
 * epel: mirrors.coreix.net
 * extras: mirror.nl.leaseweb.net
 * updates: mirror.nl.leaseweb.net
- No package texlive-extras available.
- Error: Nothing to do
jjallaire commented 9 years ago

I don't know the CentOS LaTeX packages well so I'm not sure where these styles can be found.

On Mon, Oct 12, 2015 at 1:28 AM, RYO ENG® notifications@github.com wrote:

Any solution for Centos7.

$sudo yum -y install texlive-extras Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00 epel/x86_64/metalink | 25 kB 00:00 epel | 4.3 kB 00:00http://ftp.nluug.nl/pub/os/Linux/distr/fedora-epel/7/x86_64/repodata/repomd.xml: [Errno -1] repomd.xml does not match metalink for epel Trying other mirror. epel | 4.3 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 epel/x86_64/updateinfo FAILEDhttp://ftp.nluug.nl/pub/os/Linux/distr/fedora-epel/7/x86_64/repodata/b394fc8aa99a5721ac035c79baf15195be6e4b1808058d5b202d95bf882e99c8-updateinfo.xml.bz2: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. (1/2): epel/x86_64/updateinfo | 369 kB 00:00 (2/2): epel/x86_64/primary_db | 3.5 MB 00:03 Determining fastest mirrors

  • base: mirror.nl.leaseweb.net
  • epel: mirrors.coreix.net
  • extras: mirror.nl.leaseweb.net
  • updates: mirror.nl.leaseweb.net- No package texlive-extras available.- Error: Nothing to do

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/359#issuecomment-147294903.

englianhu commented 9 years ago

How can RStudio users knit PDF especially researchers, MSc or PhD students who gonna write thesis in pdf format?

Kindly look into it?

justacec commented 9 years ago

@englianhu It is vital that the end user ensure their LaTeX distribution has the necessary elements installed. About the only thing I think that RStudio could do would be to notify the end user that certain packages are missing. But it would be way out of the swim lane for RStudio to be responsible to install these packages on the system.

That being said, Maybe it would be possible to have RStudio grab them from CTAN and place the files in the current directory. I would not want that solution because it would clutter up my system. So, I think that the best thing for RStuio (actually knitr) to do would be to inform the end user what packages are missing so they could be installed, by the end user.

As for the Centos7 issue not having a texlive-extras package. It is possible for you to install packages without yum.

https://www.ctan.org/tex-archive/macros/latex/contrib/titling?lang=en

Disclaimer: I speak only for myself and do not represent RStudio in any way.

znmeb commented 9 years ago

@jjallaire I tested RStudio / knitr on CentOS and even with the EPEL repository enabled there were quite a few LaTeX packages missing. To see this / build tests, install the 'rticles' package and try to build PDFs from the templates.

Fedora (as of Fedora 22) did have all the LaTeX pieces required, but I'm not sure how one goes about backporting those to CentOS 7. And both Debian and Ubuntu have all the LaTeX requirements.

@englianhu If you can use Fedora 22 (stable) or 23 (alpha/beta now but stable soon) instead of CentOS 7 you should be able to build most PDFs. However, if you want to use RStudio Server, you'll have to build it from source - RStudio Desktop is supported on Fedora but the Server isn't. Server does work on Fedora if you build it from source.

jjallaire commented 9 years ago

I'm not sure what we can do about this. I guess we could encourage custom LaTeX formats to directly embed more of heir required .sty and .cls files but I'm not sure if most format authors would go to this trouble just for CentOS. Or perhaps there is a way to create a mini-distribution of commonly required packages and embed it in either rmarkdown or RStudio. I'd be open to this but don't have the time to run down all of the requirements, etc. so this would have to contributed by another party.

On Fri, Oct 16, 2015 at 4:31 AM, M. Edward (Ed) Borasky < notifications@github.com> wrote:

@jjallaire https://github.com/jjallaire I tested RStudio / knitr on CentOS and even with the EPEL repository enabled there were quite a few LaTeX packages missing. To see this / build tests, install the 'rticles' package and try to build PDFs from the templates.

Fedora (as of Fedora 22) did have all the LaTeX pieces required, but I'm not sure how one goes about backporting those to CentOS 7. And both Debian and Ubuntu have all the LaTeX requirements.

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/359#issuecomment-148652433.

larsvilhuber commented 9 years ago

I believe there are two answers to this: when creating R documentation with roxygen, the LaTeX call in the background already knows how to reference Rd.sty, which is not in any LaTeX distribution, but which is required to create the .Rd files. (Rd.sty is distributed as part of the R base package) Thus, there already is a way that some R packages use to reference non-standard LaTeX classes. It would be fairly straightforward to use the same approach and include "critical" style files as part of the rmarkdown package, with a switch to include/exclude them (choose your default value).

Second, LaTeX is not a monolithic package, regardless of platform. You can install the universe of LaTeX packages in Miktex or Texlive (about 4GB) to get around such problems, but most users won't bother. You may run into similar problems elsewhere in the R universe with fonts provided by your LaTeX distribution (or not), for instance. So problems like these are likely to pop up. BUT: they are similar, and providing a small FAQ as part of the package may be useful, for instance at https://github.com/rstudio/rmarkdown/wiki/FAQ...

jjallaire commented 9 years ago

Okay, those are excellent suggestions. I believe R accomplishes the inclusion of additional sty files using the TEXINPUTS environment variable so we could likely do the same.

On Fri, Oct 16, 2015 at 8:16 AM, Lars Vilhuber notifications@github.com wrote:

I believe there are two answers to this: when creating R documentation with roxygen, the LaTeX call in the background already knows how to reference Rd.sty, which is not in any LaTeX distribution, but which is required to create the .Rd files. (Rd.sty is distributed as part of the R base package) Thus, there already is a way that some R packages use to reference non-standard LaTeX classes. It would be fairly straightforward to use the same approach and include "critical" style files as part of the rmarkdown package, with a switch to include/exclude them (choose your default value).

Second, LaTeX is not a monolithic package, regardless of platform. You can install the universe of LaTeX packages in Miktex or Texlive (about 4GB) to get around such problems, but most users won't bother. You may run into similar problems elsewhere in the R universe with fonts provided by your LaTeX distribution (or not), for instance. So problems like these are likely to pop up. BUT: they are similar, and providing a small FAQ as part of the package may be useful, for instance at https://github.com/rstudio/rmarkdown/wiki/FAQ...

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/359#issuecomment-148701528.

bwlewis commented 9 years ago

@larsvilhuber to the 2nd point, I verified that the following will work on CentOS Linux release 7.1.1503:

wget http://mirrors.ctan.org/macros/latex/contrib/titling.zip
unzip titling.zip     # (might need to sudo yum install unzip)
cd titling
latex titling.ins
sudo mkdir -p /usr/share/texlive/texmf-dist/tex/latex/titling
sudo cp titling.sty /usr/share/texlive/texmf-dist/tex/latex/titling/
sudo texhash

This generic approach will work for most CTAN packages. See http://tug.ctan.org/info/beginlatex/html/chapter5.html for more info.

mimoralea commented 8 years ago

sudo dnf install texlive-titling

Did it for me in Fedora... I supposed it'd be similar in CentOS.

znmeb commented 8 years ago

@mimoralea CentOS 7 is binary-compatible with RHEL 7. Fedora is a separate distribution. Fedora has some LaTeX packages that RHEL/CentOS don't have. Moreover, RStudio Server is not supported on Fedora, although the desktop version is. Don't get me wrong; Fedora is a fine distribution, but it's not popular enough to have widespread support like, say, Ubuntu.

For these reasons, among others, I gave up on CentOS and Fedora and switched to Debian. And on my workstation I simply install texlive-full. I wasted many hours tracking down LaTeX dependencies even on Fedora. Unless you're under some administrative constraint that forces you to use RHEL / CentOS, I'd recommend staying away from them.

pm0kjp commented 8 years ago

The bwlewis comment above also works for Fedora 22. Quoted here:

@larsvilhuber to the 2nd point, I verified that the following will work on CentOS Linux release 7.1.1503:

wget http://mirrors.ctan.org/macros/latex/contrib/titling.zip
unzip titling.zip     # (might need to sudo yum install unzip)
cd titling
latex titling.ins
sudo mkdir -p /usr/share/texlive/texmf-dist/tex/latex/titling
sudo cp titling.sty /usr/share/texlive/texmf-dist/tex/latex/titling/
sudo texhash

This generic approach will work for most CTAN packages. See http://tug.ctan.org/info/beginlatex/html/chapter5.html for more info.

znmeb commented 8 years ago

@pm0kjp Thanks!! In the unlikely event I'm forced to use RHEL / CentOS I'll keep this in mind.

tuxdna commented 8 years ago

texlive-tiling seems to be present in CentOS 7, however it is not present in latest version of Fedora ( 24 ).

@bwlewis thanks, your steps work for me on Fedora 24.

znmeb commented 8 years ago

@tuxdna "tiling" or _"titling"_?? I'm on Fedora 24:

$ dnf search texlive|grep titling
texlive-titling.noarch : Control over the typesetting of the \maketitle command
texlive-titling-doc.noarch : Documentation for titling
tuxdna commented 8 years ago

@znmeb You are right! I was using wrong spelling. This makes it super simple to setup on Fedora 24 :-)

englianhu commented 8 years ago

Installed, thanks lot.

On Fri, 16 Sep 2016 12:29 PM Saleem Ansari, notifications@github.com wrote:

@znmeb https://github.com/znmeb You are right! I was using wrong spelling. This makes it super simple to setup on Fedora 24 :-)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rstudio/rmarkdown/issues/359#issuecomment-247510296, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5IvuTkYmY7_kVhOB4mhHvO5VyXvsd_ks5qqg0wgaJpZM4DU4q6 .

®γσ, Eng Lian Hu https://beta.rstudioconnect.com/englianhu/ryo-eng/

znmeb commented 8 years ago

All: let it be noted that on my laptop (Win10 / Fedora 24 dual boot) and my workstation (Fedora 24 with numerous other distros in virtual machines) I nearly always just give up hunting for LaTeX dependencies when authoring and just install the whole TeXLive / MikTeX distribution! ;-)

znmeb commented 8 years ago

More Linux LaTeX tricks:

On Ubuntu (and probably Debian) do

sudo apt-get install apt-file
sudo apt-file update

Then, if an RStudio / Markdown operation fails on a missing LaTeX component, type apt-file search <component>. For example, if titling.sty is missing, type apt-file search titling.sty. You'll get a listing that tells you which package(s) have a file that matches the text titling.sty.

On Fedora, you don't need to install anything. Just type dnf whatprovides */<component>, e.g., dnf whatprovides */titling.sty. You'll get the package name.

This also works when installing R packages from source - if an install fails because of a missing header file you can find out which Linux package to install the same way.

GuangchuangYu commented 7 years ago

for arch:

sudo pacman -S texlive-latexextra
yunyings commented 7 years ago

Got many same errors like below when compiling project on RHEL 7.4: LaTeX Error: File `xtab.sty' not found.

Installing all textlive- packages solves the problem: `sudo yum install texlive-.el7.noarch`

elinw commented 7 years ago

I did what @yunyings suggested and it does solve that message but I got this after knitting.

PDF.js v1.3.158 (build: 944d1e6) Message: Invalid PDF structure

znmeb commented 7 years ago

Update on Arch Linux: I'm now running Arch Linux. To get all the R Markdown tools to work, I had to install three packages: texlive-most, texlive-lang and t1utils. The first two are meta-packages / package collections. As with most Linux distros, this takes up about 4 GB of disk space.

If you're writing for specific journals, you may need to install some Arch User Repository (AUR) packages. For example:

aur/texlive-aastex6 6.1-3 (1) (0.24)
    Package for preparing papers in American Astronomical Society (AAS) journals
boyko11 commented 6 years ago

Thanks to @znmeb and the post from October 12, 2016 and also @jjallaire . I got it to work on my Ubuntu 16.04: sudo apt-get install texlive-latex-extra

yihui commented 6 years ago

No matter what your OS is, there is no need to wrestle with missing LaTeX packages anymore, if you

install.packages(c('tinytex', 'rmarkdown'))
tinytex::install_tinytex()

I have been so frustrated by this problem and spent a few weeks in last December on a custom LaTeX distribution named TinyTeX. See https://yihui.name/tinytex/ for more info.

linshigreenfire commented 6 years ago

I followed the instructions below and it solve the problem.

https://www.pydanny.com/setting-up-latex-on-mac-os-x.html

Nova-Scotia commented 5 years ago

tinytex solved my problem. Thanks @yihui!

github-actions[bot] commented 4 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.