Knit as pdf not work


#1

knite as pdf file not work in my rmarkdown , he said there is missing package , i download it from internet but i do not know how i can connect with R .


#2

In order to knit pdf documents you must have installed a LaTex distribution in your system, the tinytex package might be helpful for this task.


#3

i have tynitex and latex but he ask to MiKTeX, i do not know how to do that


#4

Hey @sraab, welcome! In order to help you, we need you to make a reproducible example, or reprex. In particular, a few things would really help us get to the bottom of your problem:

  • A sample of the RMarkdown document you're trying to knit, and
  • The complete error you're getting.

Thanks!


#5

it is for regression class so have a lot of math symbol like this

$$\mathbf{X^TX}=
\left[\begin{array}
& 1 &1 &...&1 \
x_1& x_2 &...& x_n
\end{array}\right]

\left[\begin{array}
& 1 &x_1 \
1 &x_1\
.&.\
.&.\
1&x_n
\end{array}\right]

this is the error

Error: Failed to compile early_test.tex.
In addition: Warning message:
In system2(..., stdout = FALSE, stderr = FALSE) : '"pdflatex"' not found
Execution halted

No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:

Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup
(NOTE: Be sure to download the Complete rather than Basic installation)

Mac OS X: TexLive 2013 (Full) - http://tug.org/mactex/
(NOTE: Download with Safari rather than Chrome strongly recommended)

Linux: Use system package manager


#6

You say you have tinytex installed. By that, do you mean that you've run install.packages('tinytex')? Because you would also need to run tinytex::install_tinytex() to get it completely installed and configured. That might fix your problem :slight_smile:


#7

I run these

install.packages('tinytex')
tinytex::install_tinytex()

but also there is error

! LaTeX Error: Illegal character in array arg.

Error: Failed to compile early_test.tex. See early_test.log for more info.
Execution halted

No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:

  Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup
  (NOTE: Be sure to download the Complete rather than Basic installation)

  Mac OS X: TexLive 2013 (Full) - http://tug.org/mactex/
  (NOTE: Download with Safari rather than Chrome _strongly_ recommended)

  Linux: Use system package manager

#8

Can you please give us the complete output of that command, @sraab? Everything that comes out after you enter tinytex::install_tinytex(), not just the error. That might give us some context :slight_smile:


#9

no , i mean i run this tinytex::install_tinytex() , and it is ok
but after that when i go and knite as pdf , the error show


#10

Ahh, gotcha. Have you had a look at the error_test.log file referenced by the error? I've had a few LaTeX errors that weren't immediately clear until I had a look at the log file. It'll probably be quite large, but you can always just post the last section of it around the error if that's the case.


#11

Two other things re. the installation.

  1. If you're using RStudio, can you please go to Tools > Global Options > Sweave and check what's selected under "Typeset LaTeX into PDF using:" It should be either pdfLaTeX or XeLaTeX.

  2. Then, verify that R knows where Tinytex's version of those are by running Sys.which('pdflatex') or Sys.which('xelatex'). For example, when I run these I get:

> Sys.which('pdflatex')
                                                               pdflatex 
"C:\\Users\\rensa\\AppData\\Roaming\\TinyTeX\\bin\\win32\\pdflatex.exe"

> Sys.which('xelatex')
                                                               xelatex 
"C:\\Users\\rensa\\AppData\\Roaming\\TinyTeX\\bin\\win32\\xelatex.exe" 

#12

nothing show

Sys.which('pdflatex')
pdflatex
""
Sys.which('xelatex')
xelatex
""


#13

thank you it is work now but some time not work because illegal character , how i can know which character?