0

My markdown file won't knit to PDF and returns the following error:

Unmatched ( in regex; marked by <-- HERE in m//( <-- HERE .sty/ at /usr/local/bin/tlmgr line 1778. Error in grep(paste0("/", x[j], "$"), l) : invalid regular expression '/(.sty$', reason 'Missing ')'' Calls: ... system2_quiet -> on_error -> parse_packages -> grep

I am on a Mac and everything was working yesterday, and then I installed tinytex (I may have installed it twice) and now I cannot knit to PDF. Has anyone seen this error before? Or worked with tmlr?

I have tried uninstalling tinytex and reinstalling Rstudio.

If it helps, my YAML heading is:

---
title: \vspace{2in}"**Borrower Feedback Analysis**"
date: "`r Sys.Date()`"
#output: html_document
output:
  pdf_document:
    latex_engine : xelatex
    toc: true
    toc_depth: 1

header-includes:
  - \usepackage(tinytex)
  - \usepackage{sectsty}
  - \usepackage{xcolor}
  - \definecolor{blendHeaderBlue}{HTML}{00146b}
  - \definecolor{blendParahraphBlue}{HTML}{4a578f}
  - \sectionfont{\color{blendHeaderBlue}}
  - \subsectionfont{\color{blue}}
  - \paragraphfont{\color{blue}}

geometry: margin= .9in
fontsize: 10pt

---
Phil
  • 7,287
  • 3
  • 36
  • 66
Byron Pop
  • 31
  • 1
  • 8
  • It looks like a problem with the content of the document itself. What's in line `1778`, and what's going on with the `grep(paste0("/", x[j], "$"), l)` command? – 9314197 Jun 17 '20 at 15:27
  • I don't think its a problem with the content, because I only have 570 lines of code. In the tmlr.pl file, I see it has this function ```sub search_pkg_files { my ($tlp, $what) = @_; my @files = $tlp->all_files; if ($tlp->relocated) { for (@files) { s:^$RelocPrefix/:$RelocTree/:; } } my @ret = grep(m;$what;, @files); return @ret; }```. I'm not sure whether this is the issue, but I never had this issue before today which is odd, same tex document content any everything – Byron Pop Jun 17 '20 at 15:36
  • 2
    I would remove `\usepackage(tinytex)` as you don't need that, and I would check that all the latex packages have been updated. – Phil Jun 17 '20 at 15:44
  • 1
    You did it boys! Removing ```\usepackage(tinytex)``` allows it to knit properly. Thank you both so much for your help. – Byron Pop Jun 17 '20 at 15:50
  • 2
    To be clear - usage of `\usepackage()` is when you want to use a LaTeX package. tinytex is an R package that is used under the hood to knit to pdf (basically, it manages LaTeX packages for you, and avoids over-installing the abundance of packages that can come with it). Since it's not a LaTeX package, you got an error because you were looking to use something that doesn't exist according to LaTeX. Note that while there are definitely instances when you need to use tinytex explicitly, there's no point where you ever need to have a line like `library(tinytex)` in your Rmd document. – Phil Jun 17 '20 at 15:59
  • Good to know. Thank you for clarifying! – Byron Pop Jun 17 '20 at 16:03

0 Answers0