How to execxute a Latex file? - latex

everyone I'm trying to compile a latex file in Windows using MiKTeX and Texmaker. But the file is not compiling and there is showing an error as " Could not start the command.
pdflatex -synctex=1 -interaction=nonstopmode %.tex"
Can anyone help in this regard as to how this file will execute?.

Related

Compile two versions of a document from the same latex source

How to automatically compile two versions of the same document, for example version without answers for the students and another version with answers for myself?
I have a small bash script to do a dual format.
function latex-ans () {
n=$(basename $1 .tex) # strip .tex in filename foo.tex -> foo
ln -s $n.tex $n-ans.tex # create a soft link (for instance foo-ans.tex -> foo.tex)
pdflatex '\def\withanswer{1} \input{'$n-ans'}' && pdflatex $n
% first format the version with answers and then the normal version
rm $n-ans.tex $n-ans.log
% remove useless files
}
If I have a file foo.tex, this commands formats both versions of the file and generates two pdf: foo.pdf and foo-ans.pdf. Thanks to the renaming of foo.tex through the ln -s, it also keeps separate foo.aux and foo-ans.aux to preserve useful information on both versions.
At the latex level, I basically do the same and use the macro \withanswers to configure my packages.
There are several packages that allow to conditionally exclude certain parts of the document, for example the exercise package.
With TeXstudio, the following magic comment can be used to automatically compile both versions at once (including repeated compilation for cross-references, bibliographies, indices etc.):
% !TeX program = latexmk -pdf -pdflatex="pdflatex -synctex=1 -interaction=nonstopmode -shell-escape" -jobname=% -pretex="\newcommand{\version}{noanswer}" -usepretex % | latexmk -pdf -pdflatex="pdflatex -synctex=1 -interaction=nonstopmode -shell-escape" -jobname=%_solution -pretex="\newcommand{\version}{}" -usepretex % | txs:///view-pdf "?am)_solution.pdf"
\documentclass{article}
% setting a default value in case it is compiled without the magic comment
\ifdefined\version
\else
\def\version{noanswer}
\fi
\usepackage[\version]{exercise}
\begin{document}
\begin{Exercise}[title={Title},label=ex1]
question text
\end{Exercise}
\begin{Answer}[ref={ex1}]
solution
\end{Answer}
\end{document}

Unable to knit pdf from Rmardown from Rstudio in Windows 10 PC

I created a new Rmd file in the latest R and Rstudio version, and with the complete version of MiKTeX installed. In my windows 10 machine.
When I tried to knit it I got the following error
! LaTeX Error: File `fancyvrb.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.34 \newcommand
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
Además: Warning message:
comando ejecutado '"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS pdfprueba.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pdfprueba.pdf --template "C:\Users\karin\Documents\R\win-library\3.3\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' tiene estatus 43
Ejecución interrumpida
I suspected that it could have been that I didn't have the package fancyvrb in MiKTeX , so I followed these instructions but I still get the same error.
Try the same using
Miktex package manager (admin)
Under > repository check that your package repository is up to date.
In the name box type the name of your package
Then filter
then add your package
To test if your package is installed in dos CMD type
kpsewhich fancyvrb.sty. you should be able to see the path to your package.
Microsoft Windows [version 10.0.15063]
(c) 2017 Microsoft Corporation. Tous droits réservés.
C:\>kpsewhich fancyvrb.sty
C:/Users/me/AppData/Roaming/MiKTeX/2.9/tex/latex/fancyvrb/fancyvrb.sty

Undefined control sequence error while converting from markdown to PDF with pandoc and xelatex

I'm making some documentation for our project, but I can't enable xelatex in pandoc to setup custom fonts. If I set --latex-engine xelatex pandoc will show that error:
pandoc: Error producing PDF from TeX source.
! Undefined control sequence.
l.17 \sys_if_engine_luatex:T
Here is a command that I run:
pandoc -s --latex-engine xelatex -f markdown build.md -o docs.pdf
I use Ubuntu 14.04 LTS, pandoc 1.12.2.1 and XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013/Debian).
Oops... after removing texlive 2013 with apt-get and installing manualy texlive 2015 pandoc will use old texlive (!!!). After that steps and setting PATH to /usr/local/texlive/2015/bin/x86_64-linux/ pandoc will finaly compile my file with xelatex.

Output of fa2latex command from psych causing LaTeX error in pandoc

I am writing a report using knitr in RStudio. Also using the psych package for factor analysis:
```{r, results='asis'}
library(psych)
data(Thurstone)
fa.Thurstone<-fa(Thurstone)
fa2latex(fa.Thurstone)
```
When I run this code chunk it causes an error:
! LaTeX Error: Unknown float option `d'.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.124 \begin{scriptsize} \begin{table}[htdp]
pandoc: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
When I save the TeX code it runs fine in LaTeX, but not in knitr.
Any suggestions on how to resolve this?

Synchronise pdf to Rnw in Knitr with texshop

Would anyone know how to get synctex to work from the pdf to the Rnw in knitr with texshop? It does work from Rnw to pdf. Many thanks.
This is how I worked this out. Not tried on multiple .Rnw files.
In TeXShop Preferences, make sure your "Sync Method" is set as "SyncTeX (TeX ≥ 2010)".
On your Mac, make the directory "~/Library/TeXShop/Rscripts" and put the R file "patchKnitrSynctex.R" downloaded from https://github.com/jan-glx/patchKnitrSynctex in this directory.
Create an executable file "Knitr.engine" including the following shell scripts and put it in "~/Library/TeXShop/Engines/":
#!/bin/bash
# export PATH=$PATH:/usr/texbin:/usr/local/bin # already on my path!
Rscript -e "library(knitr); knit('$1')"
latexmk -pdf -pdflatex='pdflatex -shell-escape -synctex=1 -file-line-error' "${1%.*}"
Rscript -e "source('~/Library/TeXShop/Rscripts/patchKnitrSynctex.R', echo=FALSE, encoding='UTF-8'); patchKnitrSynctex('${1%.*}')"
In R, install the package "patchDVI".
In your .Rnw file, add "% !TEX TS-program = Knitr" on the top line of the document. Also inside the .Rnw document somewhere around the top of the document add an R code chunk
<<setup, include=FALSE>>=
patchDVI::useknitr()
… #any other knitr global setups
#
Happy knitting!

Resources