I'm working with LaTeX files in Sublime 3 (3059). Given a main .tex file and a .bib file holding the citations, I'd like to be able to issue the standard:
pdflatex main.tex && bibtex main.aux && pdflatex main.tex && pdflatex main.tex
command after hitting a given shortcut in Sublime.
I know there are tools that can do this (LatexTools, LaTeXing) but since what I need is (I believe) so simple, I'd prefer not to depend on extra packages.
How can I store this command and have Sublime run it following a given key combination?
Edit: Based on the answer given, this is the full command I ended up using:
{
"cmd": ["pdflatex $file_name && bibtex $file_base_name.aux && pdflatex $file_name && pdflatex $file_name"],
"shell": true
}
If you want to execute a command you could use Tools > Build System > New Build System to create a file with a content similar to this one:
{
"cmd": ["command"]
}
And then, you should select that as your project Build System. Finally, use ctrl+b to invoke build (invoke your command or script).
Related
I'm trying to use the latex graphvis package in a pandoc markdown document. However it seems to require the -shell-escape flag be passed to latex. How can I enable -shell-escape on pandoc?
\digraph[scale=0.5]{MyGraph}{
Business -- Job;
Job -- Task;
Job -- User;
Job -- PayRate;
Task -- WorkSession;
User -- WorkSession;
PayRate -- WorkSession;
}
http://mark.aufflick.com/blog/2007/03/25/embedding-graphviz-in-latex-documents
pandoc can now pass arguments directly to the LaTeX engine via the --latex-engine-opt flag. As an example, in order to pass the -shell-escape flag to xelatex you could do:
pandoc myfile.md -s -o myfile.pdf --latex-engine=xelatex --latex-engine-opt=-shell-escape
You can tell pandoc to generate LaTeX, and then do whatever you want on the output.
pandoc -o mydocument.tex mydocument.md
pdflatex -shell-escape mydocument.tex
Pandoc has a --latex-engine option to tell it to run LaTeX differently, but this can only be a path to a program called pdflatex, lualatex or xelatex. If for some reason you want to be able to generate PDF from Markdown by calling pandoc directly, you can use a wrapper script.
pandoc --latex-engine=/path/to/pdflatex -o mydocument.pdf mydocument.md
where /path/to/pdflatex is executable and contains (assuming a Unix-like system)
#!/bin/sh
exec pdflatex -shell-escape "$#"
I am receiving the below error when trying to compile Lua in Sublime Text 3.
luajit: cannot open : No such file or directory
[Finished in 0.1s with exit code 1]
[cmd: ['luajit', '']]
[dir: /Applications/Sublime Text.app/Contents/MacOS]
[path: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin]
I have tried several packages including the fixMacpaths package trying to fix this. Any ideas?
Edit: Again I have tried most of the solutions on here. This seems to be a file path issue that the mac package is not fixing.
Install Lua, in the Terminal:
curl -R -O http://www.lua.org/ftp/lua-5.3.1.tar.gz
tar zxf lua-5.3.1.tar.gz
cd lua-5.3.1
make macosx test
sudo make install
Create a build system for Lua, in Sublime 3,
goto: Tools > Build System New Build System
and enter a build configuration like the one pasted below
{
"cmd": ["lua", "$file"],
"file_regex": "^(?:(?:\t)|(?:.+: ))(.+):([0-9]+): (.*)$",
"selector": "source.lua"
}
Next, use FixMacPath to help Sublime find your programs.
git clone https://github.com/int3h/SublimeFixMacPath.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/FixMacPath
After installing FixMacPath, the user preferences in Sublime will accept additional_path_items.
Next, add addition paths. Open Sublime 3 and go to:
Sublime Text > Preferences > Settings - User and edit the file to add the paths so it can find your Lua files, for example:
{
"additional_path_items" : ["~/Documents"]
}
Next, create a file to test: "~/Documents/hello.lua"
print"Hello, World"
Finally, exit and reopen Sublime, open the test script and build ⌘b.
Tested in Mac OS X 10.10.3, Sublime 3 build 3083, Lua 5.3.1.
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!
On my MacBook (OSX Mountain Lion), I used to use this Pandoc command to convert Markdown to PDF:
$ markdown2pdf -N -o pandoc_output.pdf --xetex --toc --template=mytemplate.tex myfile.md
But markdown2pdf no longer works, and --xetex option in markdown2pdf -N -o ../../Desktop/pandoc_output.pdf --xetex --toc --template=mytemplate-headers-garamond_date.tex is deprecated.
If I do this:
$ pandoc -N -o Desktop/pandoc_output.pdf --xetex --toc --template=mytemplate.tex myfile.md
I get this:
pandoc: unrecognized option `--xetex'
But if I take out --xetex and do this:
$ pandoc -N -o Desktop/pandoc_output.pdf --toc --template=mytemplate.tex myfile.md
then I get this:
pandoc: Error producing PDF from TeX source.
! Package hyperref Error: Wrong driver option `xetex',
(hyperref) because XeTeX is not detected.
See the hyperref package documentation for explanation.
Type H <return> for immediate help.
...
l.3925 \ProcessKeyvalOptions{Hyp}
What's the solution?
Try --latex-engine=xelatex instead of --xetex
The prior answers to this question were helpful to me, as I had installed pandoc a couple years ago, but never Tex Live. Consequently I had no idea if I had installed it correctly, so putting in the entire path helped me to see that it was working, as follows:
pandoc --latex-engine=/usr/local/texlive/2012basic/bin/universal-darwin/xelatex
This is the default install location for the BasicTex setup which you download from the Pandoc install page.
I had also forgotten about using pandoc -D Latex >my-latex-template.tex to generate a template. After giving a .tex template instead of my .html one (which caused a 'you don't have BEGIN {' error) , I got .PDF: In other words, the default template worked.
Also, I had inaccurately entered -t pdf (not shown above) to set pdf as an output format, but this was not correct. The output format is Latex, which is then translated to PDF. It is not necessary to specify an output format with the dash -t option.
I hope this record of my minor stumbles saves someone some time.
See the pandoc User's Guide (or man page) for the --latex-engine option.
in blah.tex , I have a
\cite{blah}
I have a 'blah' entry in blah.bib
I run my file with :
latex blah.tex && blah.tex && dvipdf blah.dvi
The blah.pdf results in [?]
How do I fix this?
You are missing a second latex:
latex blah.tex && latex blah.tex && dvipdf blah.dvi
------------------^
If you use BibTex (which you obviously do), you'll probably have to issue the command a third time (two times after applying bibtex blah):
latex blah.tex && \ # that's for preparing for bibtex
bibtex blah && \
latex blah.tex && \ # that's for resolving the crossrefs
latex blah.tex && \ # and that for putting them in the right place
dvipdf blah.dvi
You could also adopt latexmk and not have to think about all this process anymore :)
Just do
latexmk blah
and it will take care of compiling everything the correct number of times. It's bundled with any good TeX distribution, and you can get the manual with texdoc latexmk.
Latex does not look in your .bib file - it looks in your .bbl file. Have you run bibtex on your .bib file to generate your .bbl file? Is your 'blah' entry in your .bbl file? If not, run bibtex again.
Compile it for the second time, you're done. Otherwise, clear all the auxillary files bla.tex produces and recompile twice.