28

I can't compile the most basic PDF file in R studio.

This is my error message:

output file: Report.knit.md

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

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

Enter file name: 
! Emergency stop.
<read *> 

l.3 \usepackage

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

enter image description here

# > sessionInfo()
# R version 3.1.2 (2014-10-31)
# Platform: x86_64-unknown-linux-gnu (64-bit)
# 
# locale:
#  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
# [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
# 
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# loaded via a namespace (and not attached):
# [1] digest_0.6.8      htmltools_0.2.6   rmarkdown_0.5.3.1 tools_3.1.2      
# [5] yaml_2.1.13 
geneorama
  • 3,620
  • 4
  • 30
  • 41

1 Answers1

45

As you are on an Ubuntu box:

edd@max:~$ locate lmodern.sty                ## look for this file
/usr/share/texmf/tex/latex/lm/lmodern.sty
edd@max:~$ dpkg -S $(locate lmodern.sty)     ## look for package with this file
lmodern: /usr/share/texmf/tex/latex/lm/lmodern.sty
edd@max:~$ 

indicating that you want to install the lmodern package:

sudo apt-get install lmodern

You can also search online at package.Ubuntu.com which also suggests the lmodern package.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Dirk thanks. I didn't think you could install things like this with apt-get / package managers. I had the impression that you had to use something within Latex like `tlmgr` (if that was the problem). – geneorama Mar 23 '15 at 02:33
  • 1
    I tried the dpkg-query and got dpkg-query: error: --search needs at least one file name pattern argument – Christopher J Poor Jul 12 '18 at 03:50
  • I think the second answer here https://tex.stackexchange.com/questions/75166/error-in-tex-live-font-not-loadable-metric-tfm-file-not-found is the best solution - i.e: sudo apt-get install texlive-fonts-recommended – Christopher J Poor Jul 12 '18 at 04:07
  • Yes, sometimes files moves around. You can search them at Ubuntu and Debian as my answer suggested -- that way you will know _which_ package in the distro version you use _now_ is the one you want. – Dirk Eddelbuettel Jul 12 '18 at 04:41