This is what I have done to solve the problem in Windows mainly to be able to
run in Emacs with either .org or .tex file.
Perl
To compile using latexmk require perl to be installed in your machine. Check
the path with where and ensure it’s registered in your PATH.
where.exe perl
MikTex
Install MikTex or pandoc.
Configure
Define your org-latex-pdf-process in config.el file.
(setq org-latex-pdf-process '("pdflatex -interaction nonstopmode -output-directory %o %f" "bibtex %b" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
Referencing
Read the post on referencing for org-mode. Else it can be done as the following:
Figure [[fig:solve]] skal referere figuren nedenfor.
;; #+BEGIN_SRC latex :file solve.pdf :packages '(("" "tikz")) :border 1em :results raw
;; \usetikzlibrary{arrows, shapes, positioning}
;; \begin{tikzpicture}
;; \node [draw, minimum width = 2cm, rounded corners] (kode) {R-koder};
;; \node [fill=blue!30, text depth = 1.5cm,
;; minimum width=1.5cm, scale=2, right= of kode] (ereg) {eReg};
;; \node [draw, right=2.3cm of kode] (reg) {};
;; \path [->, >=stealth, thick] (kode) edge[bend right] (reg);
;; \end{tikzpicture}
;; #+END_SRC
;; #+RESULTS: solve-figure
;; #+CAPTION: Resultat lรธsning
;; #+NAME: fig:solve
;; #+ATTR_LaTeX: :height 5cm :placement [!htb]
;; [[file:solve.pdf]]