* How to include a very complicated latex head
@ 2012-03-21 9:00 FengShu
2012-03-21 10:51 ` Alan Schmitt
2012-03-21 12:52 ` Nick Dokos
0 siblings, 2 replies; 3+ messages in thread
From: FengShu @ 2012-03-21 9:00 UTC (permalink / raw)
To: emacs-orgmode
I want to set the latex-head for latex exporting, I use
*org-export-latex-append-header*,but it seem not used by
*org-preview-latex-fragment* . is there any other way?
simple way?
#+begin_latex
\ifxetex % xelatex
\usepackage[xetex]{hyperref}
\else
\ifpdf % pdflatex
\usepackage[pdftex,unicode]{hyperref}
\else % dvipdfmx or dvips
\usepackage[dvipdfmx,unicode]{hyperref}
%\usepackage[ps2pdf,unicode]{hyperref}
\fi
\fi
\ifxetex\else\ifpdf\else
% pdftex 3.1415926-1.40.10-2.2 has trouble with it
\InputIfFileExists{zhwinfonts.tex}{}{}
\fi\fi
#+end_latex
#+begin_src emacs-lisp
(setq org-export-latex-append-header
"
\\ifxetex % xelatex
\\usepackage[hyperref,UTF8,nofonts]{ctex}
\\setCJKmainfont[ItalicFont={AR PL UKai CN}]{AR PL UMing CN}% 文鼎宋体和楷书
\\setCJKsansfont{WenQuanYi Zen Hei}% 文泉驿的黑体
\\setCJKmonofont{WenQuanYi Zen Hei}
\\usepackage[xetex]{hyperref}
\\else
\\ifpdf % pdflatex
\\usepackage[pdftex,unicode]{hyperref}
\\else % dvipdfmx or dvips
\\usepackage[dvipdfmx,unicode]{hyperref}
%\\usepackage[ps2pdf,unicode]{hyperref}
\\fi
\\fi
\\ifxetex\\else\\ifpdf\\else
% pdftex 3.1415926-1.40.10-2.2 has trouble with it
\\InputIfFileExists{zhwinfonts.tex}{}{}
\\fi\\fi
")
#+end_src
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to include a very complicated latex head
2012-03-21 9:00 How to include a very complicated latex head FengShu
@ 2012-03-21 10:51 ` Alan Schmitt
2012-03-21 12:52 ` Nick Dokos
1 sibling, 0 replies; 3+ messages in thread
From: Alan Schmitt @ 2012-03-21 10:51 UTC (permalink / raw)
To: FengShu; +Cc: emacs-orgmode
On 21 mars 2012, at 10:00, FengShu wrote:
> I want to set the latex-head for latex exporting, I use
> *org-export-latex-append-header*,but it seem not used by
> *org-preview-latex-fragment* . is there any other way?
> simple way?
I'm using this (I don't know if it's simpler or not).
Hope this helps,
Alan
;; using xelatex
;; from http://orgmode.org/worg/org-faq.html#using-xelatex-for-pdf-export
;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
;; but adapted to use latexmk 4.20 or higher.
(defun my-auto-tex-cmd ()
"When exporting from .org with latex, automatically run latex,
pdflatex, or xelatex as appropriate, using latexmk."
(let ((texcmd)))
;; default command: oldstyle latex via dvi
(setq texcmd "latexmk -dvi -pdfps -quiet %f")
;; pdflatex -> .pdf
(if (string-match "LATEX_CMD: pdflatex" (buffer-string))
(setq texcmd "latexmk -pdf -quiet %f"))
;; xelatex -> .pdf
(if (string-match "LATEX_CMD: xelatex" (buffer-string))
(setq texcmd "latexmk -pdflatex=xelatex -pdf -quiet %f"))
;; LaTeX compilation command
(setq org-latex-to-pdf-process (list texcmd)))
(add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
;; Specify default packages to be included in every tex file, whether pdflatex or xelatex
(setq org-export-latex-packages-alist
'(
("" "graphicx" t)
("" "longtable" nil)
("" "float" nil)
("" "hyperref" nil)
))
(defun my-auto-tex-parameters ()
"Automatically select the tex packages to include."
;; default packages for ordinary latex or pdflatex export
(setq org-export-latex-default-packages-alist
'(("AUTO" "inputenc" t)
("T1" "fontenc" t)
("" "fixltx2e" nil)
("" "wrapfig" nil)
("" "soul" t)
("" "textcomp" t)
("" "marvosym" t)
("" "wasysym" t)
("" "latexsym" t)
("" "amssymb" t)
))
;; Packages to include when xelatex is used
(if (string-match "LATEX_CMD: xelatex" (buffer-string))
(setq org-export-latex-default-packages-alist
'(("" "fontspec" t)
("" "xunicode" t)
("" "url" t)
("" "rotating" t)
;("american" "babel" t)
;("babel" "csquotes" t)
("" "soul" t)
)))
(if (string-match "LATEX_CMD: xelatex" (buffer-string))
(setq org-export-latex-classes
(cons '("article"
"\\documentclass[11pt,article,oneside]{memoir}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
org-export-latex-classes))))
(add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to include a very complicated latex head
2012-03-21 9:00 How to include a very complicated latex head FengShu
2012-03-21 10:51 ` Alan Schmitt
@ 2012-03-21 12:52 ` Nick Dokos
1 sibling, 0 replies; 3+ messages in thread
From: Nick Dokos @ 2012-03-21 12:52 UTC (permalink / raw)
To: FengShu; +Cc: nicholas.dokos, emacs-orgmode
FengShu <tumashu@gmail.com> wrote:
>
> I want to set the latex-head for latex exporting, I use
> *org-export-latex-append-header*,but it seem not used by
> *org-preview-latex-fragment* . is there any other way?
> simple way?
>
You are right - org-preview-latex-fragment is independent of the latex
exporter. The preview latex header is constructed (in
org.el:org-create-formula-image) like this:
,----
| (with-temp-file texfile
| (insert (org-splice-latex-header
| org-format-latex-header
| org-export-latex-default-packages-alist
| org-export-latex-packages-alist t
| org-format-latex-header-extra))
| (insert "\n\\begin{document}\n" string "\n\\end{document}\n")
| ...
`----
so you might want to experiment with the variable
org-format-latex-header-extra (and maybe some of the others as well).
Certainly far from simple: but if your trial-and-error succeed, then you
might be able to propose a simpler mechanism. Let us know.
Nick
> #+begin_latex
> \ifxetex % xelatex
> \usepackage[xetex]{hyperref}
> \else
> \ifpdf % pdflatex
> \usepackage[pdftex,unicode]{hyperref}
> \else % dvipdfmx or dvips
> \usepackage[dvipdfmx,unicode]{hyperref}
> %\usepackage[ps2pdf,unicode]{hyperref}
> \fi
> \fi
>
> \ifxetex\else\ifpdf\else
> % pdftex 3.1415926-1.40.10-2.2 has trouble with it
> \InputIfFileExists{zhwinfonts.tex}{}{}
> \fi\fi
> #+end_latex
> #+begin_src emacs-lisp
> (setq org-export-latex-append-header
> "
> \\ifxetex % xelatex
> \\usepackage[hyperref,UTF8,nofonts]{ctex}
> \\setCJKmainfont[ItalicFont=3D{AR PL UKai CN}]{AR PL UMing CN}% =E6=96=87=
> =E9=BC=8E=E5=AE=8B=E4=BD=93=E5=92=8C=E6=A5=B7=E4=B9=A6
> \\setCJKsansfont{WenQuanYi Zen Hei}% =E6=96=87=E6=B3=89=E9=A9=BF=E7=9A=84=
> =E9=BB=91=E4=BD=93
> \\setCJKmonofont{WenQuanYi Zen Hei}
> \\usepackage[xetex]{hyperref}
> \\else
> \\ifpdf % pdflatex
> \\usepackage[pdftex,unicode]{hyperref}
> \\else % dvipdfmx or dvips
> \\usepackage[dvipdfmx,unicode]{hyperref}
> %\\usepackage[ps2pdf,unicode]{hyperref}
> \\fi
> \\fi
>
> \\ifxetex\\else\\ifpdf\\else
> % pdftex 3.1415926-1.40.10-2.2 has trouble with it
> \\InputIfFileExists{zhwinfonts.tex}{}{}
> \\fi\\fi
> ")
> #+end_src
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-21 12:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-21 9:00 How to include a very complicated latex head FengShu
2012-03-21 10:51 ` Alan Schmitt
2012-03-21 12:52 ` Nick Dokos
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).