dot2tex in org-mode and latex commandline arguments - emacs

I used to make tree diagrams with dot in orgmode.
#+BEGIN_SRC dot :file hallo1_1_1.png
digraph hallo1_1_1 {
A [shape = "circle",style=filled, fillcolor=yellow]
}
#+END_SRC
Now, to pass latex commands (\def\mycommand{args})to my diagrams I would like to use dot2tex.
(the usepackages are in ~/.emacs)
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{listings}
\\usepackage{xcolor}
\\usepackage{float}
\\usepackage{soul}
\\usepackage{amssymb}
\\usepackage{hyperref}
\\usepackage{sectsty}
\\usepackage{tabularx}
\\usepackage{pbox}
\\usepackage{tikz}
\\usepackage{stackengine}
\\usepackage{verbatim}
\\usepackage{changepage}
\\usepackage{dot2texi}
\\usepackage[pdf]{graphviz}
\\usetikzlibrary{shapes,arrows}
After using in my test.org:
#+headers: :cmdline latex -shell-escape
#+BEGIN_SRC latex
\digraph[scale=0.5]{MyGraph}{rankdir=LR; a->b; b->c}
#+END_SRC
I got the warning:
The file MyGraph.pdf hasn’t been created from MyGraph.dot yet.
Run ‘dot -Tpdf -o MyGraph.pdf MyGraph.dot’ to create it.
Or invoke LATEX with the -shell-escape option to have this done
automatically.
Is it possible to add the commandline arguments in the file correctly?
I would like the commandline arguments in the file for workflow reasons.
Thank you.

Related

emacs verilog moide:full command that include verilog-library-directories

I use the Verilog mode from emacs.
My question is:
What is full syntax of command that includes verilog-library-directories ?
emacs --batch f.sv -q --eval='(setq-default verilog-typedef-regexp
".*_t$")' -f verilog-batch-auto
For including verilog libraries I use the following comment at the end of the file:
// verilog-library-flags:("-y ../rtl")
I think then you can reuse this syntax for command line.

Org Mode tangle comment

with this line in a file i'm tangling:
#+BEGIN_SRC shell :tangle ./tangle/aux.0 :comments link :paddling no
on tangling, this prompt appears:
"No comment syntax is define. Use: [ ]"
What needs to be set, or text entered in the source file to avoid the prompt?
I've tried:
# <<example>>
or
#
on the first line.
or ... comment-syntax #
after the ":comments link"
and searched the help for examples.
I'm reading the Org Manual, and emacs help, and not finding any specific instructions.
I believe your problem is because emacs cannot determine/recognise the correct mode for the exported source. As it does not recognise the mode, it cannot determine the correct comment character.
According the the org manual, the correct identifier for shell blocks is sh not shell. Try changing your line to
#+BEGIN_SRC sh :tangle ./tangle/aux.0 :comments link :paddling no

How to use vim LatexSuite with a Makefile?

I would like to type :make in Vim to compile my LaTeX document. I wrote down compilation rules in a Makefile, but as soon as I enable the LatexSuite Vim extension, the Makefile is no longer used. Instead, Vim runs latex -interaction=nonstopmode (note the absence of a filename) and hangs in that command. I did not change the g:Tex_UseMakefile option from its default 1 to 0 and according to the documentation, that should cause my Makefile to be used, but it's not.
What configuration is needed to tell LatexSuite to just use my Makefile?
LatexSuite was obtained via OpenSuSE repositories: vim-plugin-latex-20120125-21.1.1.noarch
You can override this via following setting in your vimrc.
autocmd FileType tex let g:Tex_CompileRule_dvi = 'make'
Alternatively, set makeprg in $HOME/.vim/after/ftplugin/tex.vim
set makeprg='make'
Helpful in-source documentation of file <latex-suite-root-folder>/compiler/tex.vim
Section " Customization of 'makeprg': {{{
This (g:Tex_CompileRule_dvi) is a string which should be directly be able to be cast into
" &makeprg.

ESS/AucTeX/Sweave integration

I'm using GNU/Linux distro (Arch, if that's relevant), Emacs v23.2.1, ESS v5.9 and AucTeX v11.86.
I want to setup AucTeX to recognize .Rnw files, so I can run LaTeX on .Rnw files with C-c C-c and get .dvi file automatically. I reckon it's quite manageable by editing .emacs file, but I still haven't got a firm grasp on Elisp.
Yet another problem is quite annoying - somehow, LaTeX is not recognizing \usepackage{Sweave} in preambule, so I actually need to copy Sweave.sty file (in my case located in /usr/share/R/texmf/Sweave.sty) to directory where .Rnw file is located (and I'm becoming more frustrated by the fact that this is common bug on Windows platforms!)
My question boils down to two problems:
how to make LaTeX recognize \usepackage{Sweave} (without copying Sweave.sty to "home" folder each time) [Edit: managed to do this; see comment after Dirk's answer]
how to setup AucTeX to compile .Rnw files to .dvi
That's two different questions.
For the first one, my Debian R packages make sure that there is a soft link from the $RHOME/share/texmf/ directory into the TeX file system tree, e.g. as /usr/share/texmf/tex/latex/R.
For the second question: dunno. I tend to run Sweave via a small shell script I crafted years ago even though I do all the editing in Emacs.
Edit, a few months later: Use ESS, rather than AucTeX. Then M-n s (i.e Alt-n followed by s) runs the Sweave step and M-n P runs the LaTeX compilation, with a call to Bibtex if needed.
After brief and efficient Googling, I've found this link, and at first glance, everything seems OK, but pdf file gets garbled after Sweaving... So I tackled this problem another way around: when in doubt, go bash! I've shamelessly stolen error checking function from Dirk's Sweave bash script available here. Basically, this is a workaround: R CMD Sweave gets executed on .Rnw file, hence latex comes in, and pdflatex after that...
I'll post a bash script that does the job for me. I must state that I'm not an advanced bash programmer, moreover I'm not even a programmer by vocation, so there's a great chance that this script can be optimized/written properly. Here goes:
#!/bin/bash
FILEBASE=${1%.*}
FILEXT=${1##*.}
FILEPATH=${1%/*}
TEXFILE=$FILEBASE.tex
PDFFILE=$FILEBASE.pdf
# errorexit
function errorexit () {
echo "Error: $1"
exit 1
}
# check if file exists
if [ ! -f $1 ]; then
errorexit "File $1 not found!"
else
# check for filename length
if [ ${#1} -lt 1 ]; then
errorexit "Need to specify argument file!"
else
# if filelength OK, check extension
if [ $FILEXT != "Rnw" ]; then
errorexit "You must pass Sweave (.Rnw) file!"
# finally, run Sweave
else
cd $FILEPATH && R CMD Sweave $1
# latex $TEXFILE
pdflatex $TEXFILE
# xdg-open $PDFFILE
fi
fi
fi
Then save/copy/move this script in any of echo $PATH folders (I keep mine in /usr/bin/), and make sure that it's named sweave, or choose whatever name you like, then put these lines in your .emacs file:
(global-set-key (kbd "C-c s")
(lambda ()
(interactive)
(shell-command (concat "sweave " buffer-file-name))))
Of course, you can change keybinding to suite your needs, and be sure to change sweave with script name placed in /usr/bin/.
Bare in mind that this is not an answer, but a workaround. If you have found a way to deal with AucTeX/ESS/Sweave integration, post it, and I'll give it a checkmark.
Prior to this workaround, I had to do M-n s to Sweave, followed by C-c C-c which is default keybind in AucTeX for LaTeX file compilation. Produced file is erroneous, so I had to give it a try with bash. It works for me, if you have any suggestions, please let me know.
Kind regards,
aL3xa
EDIT:
Inserted cd $FILEPATH

Emacs exporting org file as PDF in batch mode

I'm trying to export a bunch of org mode files to PDF using emacs in batch mode. So far, only export to html seems to work.
When I export to html I see the following -
U:\tmp>d:\programs\emacs-23.1\bin\emacs.exe -batch --visit=Changelog.org --funcall org-export-as-html-batch
OVERVIEW
Exporting...
Exporting...
Saving file u:/tmp/Changelog.html...
Wrote u:/tmp/Changelog.html
HTML export done, pushed to kill ring and clipboard
However, there is no function like org-export-as-pdf-batch and so I tried the following.
U:\tmp>d:\programs\emacs-23.1\bin\emacs.exe -batch --visit=Changelog.org -eval "(org-export-as-pdf \"Changelog.pdf\")"
OVERVIEW
Exporting to PDF...
Exporting to LaTeX...
Wrong type argument: number-or-marker-p, "Changelog.pdf"
Any ideas on how to export to PDF? My org-mode version is 6.35i with on Emacs 23.1. I'm on WinXP.
Mistake in calling org-export-as-pdf.
First ARG use in calling org-export-as-latex and specifies how many levels of the outline should become headlines.
Try without ARG:
C:\> emacs.exe -batch --visit=Changelog.org --funcall org-export-as-pdf