Merge remote-tracking branch 'srht/master'
[worg.git] / org-dependencies.org
blob34f9775d036efdabc4e04f31f1d9ffaec3abee14
1 #+TODO: TODO STARTED | DONE
2 #+OPTIONS: toc:t
4 # This file is released by its authors and contributors under the GNU
5 # Free Documentation license v1.3 or later, code examples are released
6 # under the GNU General Public License v3 or later.
8 * Dependencies
10 #+index: Dependencies
12 Certain parts of org-mode have dependencies on external packages. This
13 file documents these dependencies. Many sections are placeholders,
14 waiting for input. If you can, please contribute. If you think that
15 another section should be added, please add it and fill it out. Also,
16 if you spot any mistakes, omissions or superfluities, please fix
17 them. If you have an account, you can clone the Worg tree and make the
18 additions/fixes (see [[https://orgmode.org/worg/worg-about.html]] for more
19 information), but if you don't or don't want to do it yourself, that's
20 fine too: a note to the [[mailto:emacs-orgmode@gnu.org][orgmode mailing list]] will also do
21 the job. Thanks!
23 Version: Org-mode version 7.8.03 (release_7.8.03.346.g1915.dirty)
25 ** TODO Exporting in general.
27 Anything here?
29 ** STARTED LaTeX export.
31 The LaTeX class is selected using the construct
33 : #+LaTeX_CLASS: <class>
35 org-latex predefines the treatment of the following LaTeX classes article,
36 report, book, beamer - or you can roll your own. And you can, of course,
37 customize the treatment to your heart's content.  This assumes a standard
38 LaTeX install.
40 On Linux/Mac OSX/BSD, the TeXlive distribution is recommended.  On Windows,
41 most people prefer MikTeX.
43 ** Where to get packages
45 The best way to get these packages is by using the package manager that
46 comes with your operating system. These generally contain many useful LaTeX
47 packages.
49 If that is not possible, then you can get individual LaTeX packages from
50 the CTAN sites (see [[http://www.tex.ac.uk/cgi-bin/texfaq2html?label=archives][CTAN archives]] for more information), but the
51 installation process is less straightforward (but more portable): generally
52 speaking, a LaTeX package comes in two files: a .ins file and a .dtx file
53 (usually packed in a zip or tgz archive). Processing the .ins file through
54 latex separates out the code from the .dtx file and produces the pieces
55 that need to be installed on your system, but then it is up to you to
56 figure out where to copy these files on your system for TeX and friends to
57 find them. The command ``kpsewhich'' is useful here: learn to use it well.
59 Processing the .dtx file directly through latex produces the
60 documentation of the package:
62     - latex foo.ins -> foo.sty, etc.
63     - pdflatex foo.dtx -> foo.pdf
65 Those too can be installed in standard places, so that the command ``texdoc''
66 can find and display them.
68 Many questions are answered by the [[http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes][TeX FAQ]] site, although the search
69 capability is fairly primitive by today's standards: you will have to
70 search a bit more diligently.
72 *** DONE Standard classes: article, book, report, beamer
74 The LaTeX packages included by default are as follows:
76 | LaTeX package | Ubuntu container package  | Options | Comments                          |
77 |---------------+---------------------------+---------+-----------------------------------|
78 | inputenc      | texlive-latex-base        | utf8    |                                   |
79 | fontenc       | texlive-latex-base        | T1      |                                   |
80 | fixltx2e      | texlive-latex-base        |         | Various LaTeX fixes - fix-cm too? |
81 | graphicx      | texlive-latex-base        |         |                                   |
82 | longtable     | texlive-latex-base        |         |                                   |
83 | float         | texlive-latex-recommended |         | floating environments             |
84 | wrapfig       | texlive-latex-extra       |         | text wrapping around figures      |
85 | soul          | texlive-latex-extra       |         | Underline/strike through          |
86 | textcomp      | texlive-latex-base        |         | Misc text symbols                 |
87 | marvosym      | texlive-fonts-recommended |         | Euro symbol                       |
88 | wasysym       | texlive-fonts-recommended |         | Misc symbols                      |
89 | latexsym      | texlive-latex-base        |         | Math symbols                      |
90 | amssymb       | texlive-base              |         | Math symbols                      |
91 | hyperref      | texlive-latex-base        |         |                                   |
93 *** STARTED Code blocks
94 By default, code blocks are rendered as verbatim blocks on export -
95 this setting does not have any additional dependencies.  However,
96 LaTeX provides a couple of packages that produce output that most
97 people prefer: one is the ``listings'' package and the other is the
98 ``minted'' package.  Which package is used is determined by the value
99 of the variable org-latex-listings: nil means the default
100 verbatim block export, 'minted means the minted package and any
101 non-nil value other than 'minted means the listings package.
104 **** Listings package
106 On Ubuntu, listings.sty is part of the texlive-latex-recommended package.
107 If you want to use color names, you will need color.sty, part of the
108 texlive-latex-base Ubuntu package.
110 The setup is straightforward - add this to your .emacs (or equivalent):
112 #+BEGIN_SRC emacs-lisp :exports code :results none
113    (require 'ox-latex)
115    (setq org-latex-listings t)
116    (add-to-list 'org-latex-packages-alist '("" "listings"))
117    (add-to-list 'org-latex-packages-alist '("" "color"))
118 #+END_SRC
120 **** Minted package
122 Minted is an externally provided package. It consists of a couple of
123 pieces: minted.sty provides the latex interface. It calls on an
124 external python program called ``pygmentize'' to do the heavy
125 lifting. See the [[*Special note about TeX and external programs][Special note about TeX and external programs]].
127 The minted.sty package can be downloaded from CTAN:
129   http://mirror.ctan.org/macros/latex/contrib/minted.zip
131 See [[*Where to get packages][Where to get packages]] for instructions.
133 The pygmentize library can be downloaded from
135   http://pygments.org
137 and there is documentation about installation as well.
139 To use minted with org, there is no setup involved other than
140 setting org-latex-listings to minted:
142 #+BEGIN_SRC emacs-lisp
143    (setq org-latex-listings 'minted)
144 #+END_SRC
146 The minted.sty package is automatically added to the output .tex
147 file.
149 **** Special note about TeX and external programs
151 Some packages (e.g. minted.sty) try to execute an external program in
152 order to accomplish their goal, by using the so-called \textbackslash =write18=
153 construct. This is normally *prohibited* for security reasons. There
154 are various ways to allow it, some more convenient or more secure than
155 others.
157 If you use e.g. pdflatex from the command line, then in order to allow
158 such external program execution, you just add the command-line option
159 --shell-escape:
161 #+BEGIN_SRC sh
162   pdflatex --shell-escape myfile.tex
163 #+END_SRC
165 If you are exporting from org to latex and processing directly to pdf,
166 then this mechanism can be implemented by customizing
167 org-latex-to-pdf-process, which is a list of commands to execute.  By
168 default, this list consists of three repetitions of a basic pdflatex
169 command, so you need to modify each of the three instances to add the
170 --shell-escape option. NB: the three repetitions are supposed to
171 ensure that all the references in a basic tex file will be
172 resolved. This heuristic works most of the time, but not all the time.
174 A more flexible approach consists of using the texi2dvi program, which
175 analyzes logs in order to figure out what it needs to do: if the log
176 contains complaints about undefined references, then texi2dvi will
177 call pdflatex (or whatever) again in order to resolve them. In
178 addition, texi2dvi is smart enough to invoke bibtex and
179 texindex/makeindex if necessary, something that you would have to
180 specify explicitly if you don't use texi2dvi. So why not use texi2dvi
181 by default?
183 One problem is that the currently [2012-02-21 Tue] available version
184 on most OSes suffers from an obscure egrep bug, one that causes
185 mysterious failures (unless you've seen the error before).
187 If you want to take matters into your own hands, by all means fix
188 texi2dvi in your setup and use it. The bug is on line 1713 - change
189 it from 
191 #+BEGIN_SRC sh
192   echo "$command_line_filename" | $EGREP '^(/|[A-z]:/)' >&6 \
193 #+END_SRC
197 #+BEGIN_SRC sh
198   echo "$command_line_filename" | $EGREP '^(/|[A-Za-z]:/)' >&6 \
199 #+END_SRC
201 The observant reader will note that the regexps are *not* equivalent,
202 but in practice that does not matter unless you have DOS drives named
203 with one of the characters in the ASCII charset that falls between
204 ``Z'' and ``a''. If you do have drives named like this, you have more
205 immediate problems than getting org to work on your machine.
207 OK, let's assume you fixed your version of texi2dvi. How do you use
208 it? Just set
210 #+BEGIN_SRC emacs-lisp
211   (setq org-latex-to-pdf-process '("texi2dvi --pdf %f" ))
212 #+END_SRC
214 Wait a minute: where do I put the --shell-escape option? That's the
215 second problem with texi2dvi. The best way I know to have texi2dvi
216 call pdflatex with the --shell-escape option is to define the env
217 variable
219 #+BEGIN_SRC sh
220   PDFLATEX="pdflatex --shell-escape"
221   export PDFLATEX
222 #+END_SRC
224 in your .profile, .bash_profile, .login or whatever init file your
225 login shell uses. Emacs will inherit this env variable and its value
226 and when org invokes texi2dvi (which used $PDFLATEX internally),
227 everything will work out. Another method (which is probably preferred
228 by the security-conscious) is to leave it undefined. If pdflatex does
229 not end up executing external programs, there is no problem. If it does,
230 you'll get an error, so you say
232 #+BEGIN_SRC emacs-lisp
233   (setenv "PDFLATEX" "pdflatex --shell-escape")
234 #+END_SRC
236 to your emacs and everything will work as before. The only problem is
237 that the error is usually well hidden, so you'll have to dig to find it.
238 For example, trying to export this file to PDF with PDFLATEX undefined,
239 gives me the following error:
241   =PDF file /home/nick/src/emacs/org/Worg/org-dependencies.pdf was not produced=
243 But if I export to latex and try it from the command line:
245 #+BEGIN_SRC sh
246 pdflatex org-dependencies.tex
247 #+END_SRC
249 the error is clear:
251   =! Package minted Error: You must invoke LaTeX with the -shell-escape flag.=
253 Achim Gratz suggested a different, less intrusive method on the mailing list:
254 #+BEGIN_QUOTE
255 > 2) put this in ~/.profile:
256 >    PDFLATEX="pdflatex --shell-escape"
257 >    export PDFLATEX
259 You might not want to do this either.  The canonical way to set the
260 environment for a single command is to define it right there with the
261 invocation of the command.
263  (setq org-latex-to-pdf-process '("PDFLATEX=\"pdflatex --shell-escape\" texi2dvi -p %f"))
265 Or if your system still had the locale bug even
267  (setq org-latex-to-pdf-process '("LC_ALL=C PDFLATEX=\"pdflatex --shell-escape\" texi2dvi -p %f"))
269 #+END_QUOTE
271 *** STARTED Symbols
273 LaTeX syntax can be used to introduce many special symbols into a
274 document (e.g. mathematical symbols). Most of these symbols are
275 defined by basic LaTeX, but some require the presence of extra
276 packages.
278 | LaTeX macro | Rendered Symbol (approx) | LaTeX package | Ubuntu container package  |
279 |-------------+--------------------------+---------------+---------------------------|
280 | =\EUR=      | \EUR                     | marvosym      | texlive-fonts-recommended |
281 | =\euro=     | \euro                    | eurosym       | texlive-fonts-recommended |
283 Note that marvosym is now included as part of the default setup so you do
284 not need to include the package explicitly.
286 ** STARTED PDF export.
288 PDF export goes through LaTeX export first, so all the LaTeX dependencies
289 apply here as well.
291 Certain PDF viewers have been reported to produce more or less unreadable
292 files if Adobe Type3 fonts are used in the document.  Evince has been
293 identified as one of those. One way around this problem is to not use Type3
294 fonts. Another is to use a viewer that does not mistreat Type 3 fonts.
296 You can find more information about this problem in the TeX FAQ:
298 To find out whether a document uses Type3 fonts, open it with Acrobat
299 Reader/Evince, select Properties from the File menu and then select the
300 Fonts tab; alternatively, use the pdffonts program (part of the xpdf-reader
301 package) from the command line.
303 It is probably impossible to get rid of Type3 fonts completely
304 (particularly if you are using special symbols or languages that don't use
305 the Latin alphabet: in such cases, font availability is more limited and
306 you just might not be able to find Type1 fonts to do the job).
308 For standard latin-alphabet languages that use the Computer Modern fonts
309 (including small variations e.g. Polish and Czech), you *can* find Type1
310 versions: (XXX-needs fixing) the texlive-fonts-extra package (on
311 Ubuntu/Debian) e.g. includes the AMS CM fonts which work well.  Similar
312 packages exist for other Linux distributions and probably for other
313 operating systems as well.
315 | Type1 font      | LaTeX package | Ubuntu container package |
316 |-----------------+---------------+--------------------------|
317 | Computer Modern | amsfonts      | texlive-base             |
318 | Euler           |               |                          |
320 (/XXX-needs fixing)
322 ** TODO DocBook export.
324 ** STARTED HTML export.
326 *** STARTED Exporting LaTeX fragments as images.
328 LaTeX fragments can be exported as images for inclusion into HTML
329 documents. For example, complicated mathematical expressions can be
330 dealt with this way. This is done by creating a LaTeX file that
331 contains the fragment, processing it through LaTeX to produce a DVI
332 file and then processing it through dvipng. So, in addition to LaTeX,
333 you will need dvipng: on Ubuntu, this is available in the "dvipng"
334 package.
336 The LaTeX file contains a somewhat different list of LaTeX packages.  Note
337 that this is the default list, determined by the value of the variable
338 ``org-format-latex-header''.
340 | LaTeX package | Ubuntu container package | Options  |
341 |---------------+--------------------------+----------|
342 | amssymb       | texlive-base             |          |
343 | color         | texlive-latex-base       | usenames |
344 | amsmath       | texlive-latex-base       |          |
345 | latexsym      | texlive-latex-base       |          |
346 | eucal         | texlive-base             | mathscr  |
348 ** TODO org-plot
350 ** STARTED org-babel
352 For evaluating code blocks in some language, you need at the very
353 least, the interpreter for the language.