Mercurial > emacs
comparison lisp/org/org-latex.el @ 107863:594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-insert-link): Find the link buffer on visible
frames.
(org-export-latex-default-packages-alist): hyperref must be loaded
late.
(org-open-file): More care with the new matching for file links.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-preprocess): Do not yet protect
defined entities - these will be taken care of later.
(org-export-latex-special-chars): Post-process entity replacement.
(org-export-latex-fontify-headline): Do not yet protect defined
entities - these will be taken care of later.
(org-export-latex-tables, org-export-latex-links): Format the
caption properly.
* org-entities.el (org-entities-user): Fix typo.
* org.el (org-prepare-agenda-buffers): Uniquify TODO keywords
* org-entities.el (org-entities-user): Improve docstring.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-entities.el (org-macs): Require org-macs, to be sure that we
have `declare-function' defined.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-classes): Update docstring.
* org.el (org-format-latex-header): Add cookies to the header.
(org-splice-latex-header): Implement placement according to
cookies.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-publish.el (org-publish-aux-preprocess): Control case
sensitivity.
2010-04-10 Bastien Guerry <bzg@altern.org>
* org.el (org-splice-latex-header): Fix typo.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-make-header): Use
`org-splice-latex-header' to build the header.
(org-export-latex-classes): Update docstring.
* org.el (org-splice-latex-header): New function.
(org-create-formula-image): Use `org-splice-latex-header' to build
the header.
* org-gnus.el (org-gnus-follow-link): Handle nndoc backend.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-export-latex-packages-alist)
(org-export-latex-default-packages-alist): Fix docstring to
reflect the expected structure.
* org-docbook.el (org-docbook-do-expand): Fix bug with variable names.
(org-export-docbook-finalize-table): Make use of label for tables.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-attach.el (org-attach-commit): Split on newlines.
* org.el (org-export-latex-default-packages-alist): Use list
instead of cons for the entries.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-entities.el (org-entity-get-representation): Catch the case
that there is not entry in the list.
* org-mobile.el (org-mobile-use-encryption)
(org-mobile-encryption-tempfile, org-mobile-encryption-password):
New options.
(org-mobile-check-setup): CHeck the encryption setup.
(org-mobile-copy-agenda-files, org-mobile-sumo-agenda-command)
(org-mobile-create-sumo-agenda): Use encryption code.
(org-mobile-encrypt-and-move): New function.
(org-mobile-encrypt-file, org-mobile-decrypt-file): New
functions.
(org-mobile-move-capture): Decrypt the capture file.
* org.el (org-entities): Require the new file.
(org-export-latex-default-packages-alist): New variable.
(org-complete): Use new entity code for completion.
(org-create-formula-image): Use the new packages variable.
* org-latex.el (org-export-latex-classes): Remove the standard
packages from the class headers.
(org-export-latex-make-header): Use the new package variable.
(org-export-latex-special-chars): Better regexp for entities, to
support entity name that contain numbers.
(org-export-latex-treat-backslash-char): Use the new entity code.
* org-html.el (org-html-do-expand): Use the new entity code.
* org-exp.el (org-export): Add the new export commands.
(org-html-entities): Constant removed.
(org-export-visible): Add the new export commands.
* org-entities.el: New file.
* org-docbook.el (org-docbook-do-expand): Use new entity code.
* org-ascii.el (org-export-ascii-entities): New variable.
(org-export-as-latin1, org-export-as-latin1-to-buffer)
(org-export-as-utf8, org-export-as-utf8-to-buffer): New commands.
(org-export-as-encoding): New function.
(org-export-ascii-preprocess): Call `org-ascii-replace-entities'.
(org-ascii-replace-entities): New function.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-html.el (org-html-level-start): Catch the case that target
might be nil.
2010-04-10 Dan Davison <davison@stats.ox.ac.uk>
* org.el (org-appearance): Change Customize group variable name
from org-font-lock to org-appearance, and change tag from "Org
Font Lock" to "Org Appearance"
(org-odd-levels-only): Change Customize group variable name
(org-level-color-stars-only): Change Customize group variable name
(org-hide-leading-stars): Change Customize group variable name
(org-hidden-keywords): Change Customize group variable name
(org-fontify-done-headline): Change Customize group variable name
(org-fontify-emphasized-text): Change Customize group variable name
(org-fontify-whole-heading-line): Change Customize group variable name
(org-highlight-latex-fragments-and-specials): Change Customize
group variable name
(org-hide-emphasis-markers): Change Customize group variable name
(org-emphasis-alist): Change Customize group variable name
(org-emphasis-regexp-components): Change Customize group variable
name
(org-modules): Remove mention of org-R
* org-faces.el (org-faces): Change Customize group variable name
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-diary-last-run-time): New variable.
(org-diary): prepare agenda buffers only if last call was some
time ago.
* org-html.el (org-export-html-preprocess): Replace \ref macros
with a link.
(org-format-org-table-html): Add the label as an anchor.
* org-docbook.el (org-export-docbook-format-image): Do some
formatting on captions.
* org-latex.el (org-export-latex-tables, org-export-latex-links):
Do some formatting on captions.
* org-html.el (org-export-html-format-image)
(org-format-org-table-html): Do some formatting on captions.
2010-04-10 Dan Davison <davison@stats.ox.ac.uk>
* org.el (org-hidden-keywords): New customizable variable. This is
a list of symbols specifying which of the special keywords #+DATE,
#+AUTHOR, #+EMAIL and #+TITLE should be hidden by font lock.
(org-fontify-meta-lines-and-blocks): Changes to font-lock code
implementing new faces and hiding behaviour.
* org-faces.el (org-document-title): New face for #+TITLE lines
(org-document-info): New face for #+DATE, #+AUTHOR, #+EMAIL lines
(org-document-info-keyword): New face for #+DATE, #+AUTHOR, #+EMAIL keywords
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-publish.el (org-publish-sanitize-plist): New function to
rename "index" properties to "sitemap". Do this renaming
globally.
(org-publish-with-aux-preprocess-maybe): New macro.
(org-publish-org-to-pdf, org-publish-org-to-html): Use the new
macro.
(org-publish-aux-preprocess)
(org-publish-index-generate-theindex.inc): New function.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-table.el (org-table-align): Interpret <N> at fixed width,
not as maximum width.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-author-info, org-export-email-info): Fix
docstrings.
* org-beamer.el (org-beamer-select-environment): Renamed from
`org-beamer-set-environment-tag'. Improve docstring.
* org-freemind.el (org-freemind-write-mm-buffer): Fix another
problem with odd levels.
* org-ascii.el (org-export-as-ascii): Export email only if the
author wants it.
* org-docbook.el (org-export-as-docbook): Export email only if the
author wants it.
* org-html.el (org-export-as-html): Export email only if the
author wants it.
* org-exp.el (org-export-email-info): New option.
(org-export-plist-vars): Add entry for `org-export-email'.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-table.el (org-table-goto-line): Fix typo.
2010-04-10 Mikael Fornius <mfo@abc.se>
* org.el (org-agenda-files): Typo.
(org-read-agenda-file-list): Add optional argument to help
`org-store-new-agenda-file-list' to remember un-expanded file
names. Expand file names relative to `org-directory'.
(org-store-new-agenda-file-list): Keep un-expanded file names when
saving, if available.
(org-agenda-files): Update documentation.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-ascii.el (org-export-as-ascii): Catch the case of exporting
a buffer with no file name attached.
* org.el (org-log-refile): New option.
(org-log-note-headings): Add a heading for refiling.
(org-startup-options): Add keywords for logging of the refile
action.
(org-refile): Add logging action.
(org-add-log-note): Allow for refiling action.
* org-agenda.el (org-agenda-bulk-action): Make sure
`org-log-refile' is not `note' during a bulk action.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-map-dblocks): Use save-excursion to remember the
position.
* org-attach.el (org-attach-commit): Remove dependence on xargs.
(org-attach-delete-one): Commit after deleting a file.
* org-latex.el (org-export-latex-fontify): Do not mistake table.el
borders for strike-through emphasis.
* org-freemind.el (org-freemind-write-mm-buffer): Simplify the
handling of odd levels.
* org-agenda.el (org-agenda-todo-ignore-deadlines): Document `past'
and `future' values.
(org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item):
Handle `past' and `future' values.
* org.el (org-read-agenda-file-list): Interpret file names
relative to org-directory and allow environment variables and
"~".
* org-latex.el (org-export-latex-special-chars): Allow a
parenthesis before an exponent or subscript.
2010-04-10 Dan Davison <davison@stats.ox.ac.uk>
* org-src.el (org-edit-src-exit): When returning from code edit
buffer, if code block is hidden, leave point at start of
#+begin_src line
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-insert-heading): Do not remove all spaces if the
headline is empty.
* org-indent.el (org-indent): Fix group name.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-table.el (org-table-goto-column): Fix forcing a non-existing
column.
(org-table-get, org-table-put, org-table-goto-line)
(org-table-current-line): New functions.
2010-04-10 Jan Bcker <jan.boecker@jboecker.de>
* org.el (org-open-file): Allow regular expressions in
org-file-apps to capture link parameters using groups. In a
command string to be executed, the parameters can be referenced
using %1, %2, etc. Lisp forms can access them using
(match-string n link).
(org-apps-regexp-alist): Adopt the created regexp, as this is now
matched against a file: link instead of the file name.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-crypt.el (org-reveal-start-hook): Add a decryption function
to this hook.
(org-decrypt-entries, org-encrypt-entries, org-decrypt-entry): Add
docstrings.
* org.el (org-point-at-end-of-empty-headline)
(org-level-increment, org-get-previous-line-level): New function.
(org-cycle-level): Rewritten to be independent of when this
function is called.
(org-in-regexps-block-p): New function.
(org-reveal-start-hook): New hook.
(org-reveal): Run new hook.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-keywords): Start a new paragraph
after time keywords, do not add "\newline".
* org-html.el (org-export-as-html): Avoid double # in href.
* org.el (org-refile-get-location): Catch an invalid target
specification.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file):
Make sure the behavior regarding to extracting time is
consistent.
2010-04-10 Stephen Eglen <stephen@gnu.org>
* org-agenda.el (org-agenda-insert-diary-extract-time): New
variable.
(org-agenda-add-entry-to-org-agenda-diary-file): Use this new
variable rather than `org-agenda-search-headline-for-time'.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-list.el (org-fix-bullet-type): Improve cursor positioning.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-adaptive-fill-regexp-backup): New variable.
(org-set-autofill-regexps): Store a backup of
`adaptive-fill-regexp'.
(org-adaptive-fill-function): Fix filling of comments and ordered
lists. If there is no other match, till try adaptive fill.
2010-04-10 John Wiegley <jwiegley@gmail.com>
* org-agenda.el (org-agenda-include-deadlines): Added new
customization variable to determine whether unscheduled tasks
should appear in the agenda solely because of their deadline.
Default to true, which was the previous behavior (it just wasn't
configurable).
(org-agenda-mode-map, org-agenda-view-mode-dispatch): Bind ! in
the agenda to show/hide deadline tasks.
(org-agenda-menu): Added menu option for show/hide deadlines.
(org-agenda-list): Make the agenda list sensitive to the value of
`org-agenda-include-deadlines'.
(org-agenda-toggle-deadlines): New function to toggle the value of
`org-agenda-include-deadlines' and repaint the modeline
indicators.
(org-agenda-set-mode-name): Show "Deadlines" in the agenda
modeline if deadline tasks are being displayed.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-table.el (org-table-eval-formula): Replace $# and @# by
current column and row number.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-set-property, org-delete-property): Go back to
prompting for the property.
* org-latex.el (org-export-latex-make-header): Fully process
author line.
(org-export-latex-fontify-headline): Allow several arguments, not
just one.
(org-export-latex-fix-inputenc): Catch the error when
`latexenc-coding-system-to-inputenc' is not defined.
* org-agenda.el (org-agenda-skip-if-todo): New function.
(org-agenda-skip-if): Add conditions for TODO keywords.
(org-agenda-skip-if): Document the new todo conditions.
2010-04-10 Mikael Fornius <mfo@abc.se>
* org.el (org-at-property-p): Check if we are inside a property
drawer not just any drawer.
(org-set-property, org-delete-property): When cursor is on a
property key value pair do not prompt for property name instead
use name at cursor.
(org-ctrl-c-ctrl-c): Still do org-property-action when cursor is
on the first line of a property drawer.
(org-property-end-re): Spell check.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-attach-captions-and-attributes): Add the
properties to the entire table, in case the first line is
removed.
* org-archive.el (org-archive-reversed-order): New option.
(org-archive-subtree, org-archive-to-archive-sibling): Use the new
option `org-archive-reversed-order'.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-entry-types): New variable.
(org-agenda-list): Use `org-agenda-entry-types'.
(org-agenda-custom-commands-local-options): Support for setting
`org-agenda-entry-types' as an option.
(org-diary): Shift some documentation from here to the variable
`org-agenda-entry-types'.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-make-header): Apply macros in
author field.
* org-clock.el (org-clocking-buffer, org-clocking-p): New function.
(org-clock-select-task, org-clock-notify-once-if-expired)
(org-clock-in, org-clock-out, org-clock-cancel, org-clock-goto)
(org-clock-out-if-current, org-clock-save): Use the new functions.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-docbook.el (org-export-as-docbook): Remove unnecessary
newline.
(org-export-as-docbook): Remove unnecessary newline.
(org-export-as-docbook): Fix problem with double footnote
reference in one place.
* org-exp.el (org-export-format-source-code-or-example): Remove
unnecessary newline.
* org.el (org-deadline, org-schedule): Allow rescheduling entries
with repeaters.
* org-table.el (org-table-convert-refs-to-rc): Better way to catch
function calls that look like references.
* org.el (org-open-at-point): Get link abbreviations from
reference buffer.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-table.el (org-table-convert-refs-to-rc): Do not read arctan2
as a reference.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-link-unescape): Solve issue with lower-case escapes.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-classes): Add
\usepackage{latexsym} to all classes.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-html.el (org-export-as-html): Do not allow protected lines
into the table of contents.
* org-latex.el (org-export-latex-special-chars): Find subsequent
occurrences of special characters.
(org-export-latex-tables): Do not convert table-like stuff that is
protected.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-list.el (org-toggle-checkbox): No errors when updating
checkbox count fails because there is no heading.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-report-include-clocking-task): New
option.
(org-clock-sum): Add the current clocking task.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-cycle): Print a message when in a table.el table.
(org-edit-special): Recognize the table.el context.
(org-ctrl-c-ctrl-c): Print a message when in a table.el table.
* org-src.el (org-at-table.el-p): Declare.
(org-edit-src-code): Handle a special case for table.el editing.
(org-edit-src-find-region-and-lang): Recognize the table.el
context.
* org-latex.el (org-export-latex-tables): Convert table.el
tables.
(org-export-latex-convert-table.el-table): New function.
* org-html.el (org-html-expand): Fix table.el export.
* org-latex.el (org-export-latex-preprocess): Protect footnotes in
headings.
* org-id.el (org-id-find-id-file): Fix bug when there is no hash
table for the id locations.
* org.el (org-read-date-analyze): Match American-style dates, like
5/30 or 5/13/7. Make sure cal-iso.el is loaded. Don't force he
current year when reading ISO and American dates.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-face-from-face-or-color): New function.
(org-get-todo-face, org-font-lock-add-priority-faces)
(org-get-tag-face): Use `org-face-from-face-or-color'.
* org-faces.el (org-todo-keyword-faces, org-priority-faces): Allow
simple colors as values.
(org-faces-easy-properties): New option.
* org-agenda.el (org-agenda-set-mode-name): Show if the agenda is
restricted, as an agenda mode.
(org-agenda-fontify-priorities): Allow simple colors as values.
2010-04-10 Bastien Guerry <bzg@altern.org>
* org-timer.el (org-timer-current-timer): Renamed from
`org-timer-last-timer'.
(org-timer-timer1, org-timer-timer2, org-timer-timer3): Removed.
(org-timer-cancel-timer, org-timer-show-remaining-time)
(org-timer-set-timer): Update to use only one timer.
* org.el (org-set-property): Remove useless space in the prompt.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-html.el (org-export-html-style-default): Add a default style
for textareas.
* org-exp.el (org-export-format-source-code-or-example): Fix
textarea tag.
2010-04-10 Bastien Guerry <bzg@altern.org>
* org-clock.el (org-clock-current-task): New variable to store
last clocked in task.
(org-clock-set-current, org-clock-delete-current): New functions.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-remember.el (org-remember-apply-template): Extend comment.
(org-remember-handler): Implement clock sibling filing.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-publish.el (org-publish-all, org-publish-current-file)
(org-publish-current-project): When called with prefix argument
FORCE, also rebuild the validation file list.
* org-latex.el (org-export-latex-preprocess): Protect footnotes in
section headings.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-html.el (org-export-as-html-and-open): Kill product buffer
if the user wants that.
* org-latex.el (org-export-as-pdf-and-open): Kill product buffer
if the user wants that.
* org-exp.el (org-export-kill-product-buffer-when-displayed): New
option.
* org-agenda.el (org-batch-agenda-csv): Use the time property
instead of the `time-of-day' property.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-timer.el (org-timer-start-hook, org-timer-stop-hook)
(org-timer-pause-hook, org-timer-set-hook)
(org-timer-cancel-hook): New hooks.
(org-timer-start): Run `org-timer-start-hook'.
(org-timer-pause-or-continue): Run `org-timer-pause-hook'.
(org-timer-stop): Run `org-timer-stop-hook'.
(org-timer-cancel-timers): Run `org-timer-cancel-hook'.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-reveal): Double prefix arg shows the subtree of the
parent.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-search-view): Fix bug with searching full
words in headlines in search view.
(org-agenda-skip-deadline-prewarning-if-scheduled): New option.
(org-agenda-get-deadlines): Suppress pre-warning if the entry is
scheduled (if the user configures it so.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-hide-archived-subtrees): Don't jump to end of
subtree if the match was not in a headline.
(org-inside-latex-macro-p): Allow more complex arguments.
(org-emphasize): Protect against use at end of buffer.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-align-tags): Avoid side effects on
text properties.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-todo-ignore-scheduled): More allowed
values.
(org-agenda-todo-ignore-scheduled)
(org-agenda-todo-ignore-deadlines): More control with different
allowed values.
(org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item):
Honor the new option settings.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-get-location): Make sure the selection buffer is
shown in the current frame.
* org-ascii.el (org-export-ascii-table-widen-columns): New
option.
(org-export-ascii-preprocess): Realign tables to remove narrowing
if `org-export-ascii-table-widen-columns' is set.
* org-table.el (org-table-do-narrow): New variable.
(org-table-align): Narrow only if `org-table-do-narrow' is t.
* org.el (org-deadline, org-schedule): Allow updating if the
relevant time stamp does not have a repeater, i.e. do not require
that no time stamp has a repeater.
* org-agenda.el (org-agenda-align-tags): Don't add a face to the
new white space before the tags.
* org-latex.el (org-export-as-latex): Do nit require the buffer to
be visiting a file when only exporting to a buffer or string.
(org-export-latex-fix-inputenc): Only save the buffer is there is
a file name attached to it.
2010-04-10 Dan Davison <davison@stats.ox.ac.uk>
* org-src.el (org-edit-src-exit): Widen before exiting edit buffers
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-fontify-meta-lines-and-blocks): Honor
`org-fontify-quote-and-verse-blocks'.
* org-faces.el (org-fontify-quote-and-verse-blocks): New option.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-open-at-point): Also check for text property
org-linked-text before offering collected links.
2010-04-10 Stephen Eglen <stephen@gnu.org>
* org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file):
Optionally extract time specification from text and add to the
timestamp.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-html-entities): Fix typo.
* org-latex.el (org-export-latex-make-header): Use \providecommand
to make sure the \alert macro is defined.
* org.el (org-format-latex-signal-error)
(org-create-formula-image): Use `org-format-latex-signal-error'.
2010-04-10 Stephen Eglen <stephen@gnu.org>
* org.el (org-store-link): For dired buffers, use
default-directory as link name if dired-get-filename returns
nil.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-concatenate-multiline-links): The for
protectedness at beginning of match.
* org-latex.el (org-export-latex-fix-inputenc): Never leave the
AUTO as a coding system, instead default to utf8.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-block-todo-from-children-or-siblings-or-parent)
(org-block-todo-from-checkboxes): Respect the local variable
value when deciding if blocking should be active.
* org-latex.el (org-export-latex-make-header): Define the align
macro if it is not yet defined.
* org-agenda.el (org-agenda-insert-diary-make-new-entry): Call
`org-insert-heading' with the INVISIBLE-OK argument.
* org-mac-message.el (org-mac-message-insert-flagged): Call
`org-insert-heading' with the INVISIBLE-OK argument.
* org.el (org-insert-heading): New argument INVISIBLE-OK.
* org-agenda.el (org-agenda-view-mode-dispatch): Improve the
prompt message.
* org-html.el (org-html-level-start): Use the
`html-container-class' text property to set an additional class
for an outline container.
* org-exp.el (org-export-remember-html-container-classes): New
function.
(org-export-preprocess-string): Call
`org-export-remember-html-container-classes'.
* org.el (org-cycle): Mention level cycling in the docstring.
(org-default-properties): Add new property HTML_CONTAINER_CLASS.
* org-remember.el (org-remember-apply-template): Do file insertion
first.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-habit.el (org-habit-insert-consistency-graphs): Fix a
problem with mis-aligned graphs when showing habits.
2010-04-10 Mikael Fornius <mfo@abc.se>
* org.el (org-assign-fast-keys): Prefer keys used in keyword name
when assigning. Begin using numerical characters when all in name
is used up. This is to spare alphanumeric characters for better
match with other keywords.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-preprocess-hook): Improve documentation.
* org-latex.el (org-export-latex-preprocess): More consistent
conversion and protection of the words LaTeX and TeX.
(org-export-latex-fontify-headline, org-export-latex-preprocess):
Allow angle brackets in commands, for beamer.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-in): Improve the look of the clock line
by formatting links.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-classes): Use AUTO as the place
holder string for the coding system. And improve the
documentation.
(org-export-latex-fix-inputenc): Only modify the coding system if
it is given by the placeholder AUTO.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-task-overrun-text): New option.
(org-task-overrun, org-clock-update-period): New variables.
(org-clock-get-clock-string, org-clock-update-mode-line): Mark
overrun clock.
(org-clock-notify-once-if-expired): Check if clock is overrun.
* org-faces.el: New face `org-mode-line-clock-overrun'.
2010-04-10 Jan Bcker <jan.boecker@jboecker.de>
* org.el (org-narrow-to-subtree): Position the end of the narrowed
region before the line with the next heading, to prevent the user
from prepending text to the next headline.
2010-04-10 Stephen Eglen <stephen@gnu.org>
* org-agenda.el (org-get-time-of-day): Use
org-agenda-time-leading-zero to allow leading zero (rather than
space) for times.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-diary-entry-in-org-file): Make sure
org-datetree.el is loaded.
* org-datetree.el: autoload `org-datetree-find-day-create'
* org-latex.el (org-export-latex-hyperref-format): New option.
(org-export-latex-links): Use `org-export-latex-hyperref-format'.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-ctags.el (org-ctags-enable): Change order of functions.
(org-ctags-create-tags): Add wildcard to file name expansion.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-entry-properties): Fix some important bugs.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-link-unescape, org-link-escape): Only use hexlify if
the table is not explicitly given.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-out-when-done): Allow a list of keywords
as value.
(org-clock-out-if-current): Work with the new list value of
`org-clock-out-when-done'.
(org-clock-out, org-clock-out-if-current): Avoid circular logic
between clocking out and state changes.
* org-ctags.el (org-ctags-path-to-ctags): Better system-type test.
* org-latex.el (org-export-latex-treat-backslash-char): Do not by
accident protect a character that is before a backslash.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-diary-class): Use
`org-order-calendar-date-args'.
* org.el (org-order-calendar-date-args): New function.
* org-exp.el (org-export-target-internal-links): Check for
protectedness after the first bracket.
* org.el (org-entry-properties): Don't match wrong-case TODO
keywords.
* org-agenda.el (org-agenda-schedule, org-agenda-deadline):
Document that ARG is passed through to remove the date.
(org-agenda-bulk-action): Accept prefix arg and pass it on. Do
not read a date when the user has given a `C-u' prefix.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-fix-displayed-tags): Fix bug when all
tags are hidden.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-fix-inputenc): New function.
(org-export-latex-inputenc-alist): New option.
* org-exp.el (org-export): New key SPC to publish enclosing
subtree.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-indent.el (org-indent-add-properties): Catch case when there
is no headline in the buffer.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-html-entities): Add checkmark symbol.
* org-ascii.el (org-export-ascii-preprocess): Protect targets in
verbatim code for ASCII export.
* org.el (org-update-statistics-cookies): Also see checkboxes in
ordered lists.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-view-mode-dispatch): Define the `L'
key.
* org-beamer.el (org-beamer-amend-header): Change the location
where `org-beamer-header-extra' is inserted.
* org.el (org-compute-latex-and-specials-regexp): Don't do BIND
just for computing this regexp.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-beamer.el (org-beamer-frame-default-options): New option.
(org-beamer-sectioning): Use default options if the user does not
have defined any.
(org-beamer-fix-toc): Put a frame around the table of contents.
* org-exp.el (org-export-remove-comment-blocks-and-subtrees): Make
sure case-folding works well when processing comment stuff.
* org-latex.el (org-export-latex-after-save-hook): New hook.
(org-export-as-latex): Run the new hook.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-beamer.el (org-beamer-environments-default): Add the note
environments.
(org-beamer-after-initial-vars): Allow several BEAMER_HEADER_EXTRA
lines and collect and combine the content.
(org-beamer-after-initial-vars): Check for note tags and make sure
they will be seen like a property.
* org.el (org-offer-links-in-entry): Fix bug when there is a
single link.
* org-exp.el (org-export): Make sure the mark is activated, also
when `transient-mark-mode' is off.
* org-agenda.el (org-agenda-search-view-always-boolean): New option.
(org-agenda-search-view-search-words-only): Obsolete variable, is
now an alias for `org-agenda-search-view-always-boolean'.
(org-agenda-search-view-force-full-words): New option.
(org-search-view): Improve docstring, and implement a better logic
for Boolean and phrase searches.
(org-agenda-last-search-view-search-was-boolean): New variable.
(org-agenda-manipulate-query): Consider the type of the last
search when modifying the search string.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-as-latex): Do the first letbind in the
right moment.
* org-agenda.el (org-get-entries-from-diary): Add the new face to
these entries.
* org-faces.el (org-agenda-diary): New face.
* org.el (org-make-link-regexps): Allow regexp-special characters
in link types.
(org-open-file): When in-emacs is `system', also force system
opening, like when the value was `(16)'.
(org-update-statistics-cookies): Handle entries without children.
* org-exp.el
(org-export-preprocess-before-normalizing-links-hook): New hook.
(org-export-preprocess-string): Run the new hook.
* org.el (org-offer-links-in-entry): Make RET open all links.
* org-html.el (org-export-as-html): Remove any leftover display
properties in the html file.
* org-wl.el (org-wl-store-link): Work-around for format bug with
text properties.
* org-habit.el (org-habit-insert-consistency-graphs): Turn off
invisibility while adding the graphs.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-remember.el (org-select-remember-template): Use C letter to
customize remember templates.
* org-agenda.el (org-agenda-bulk-mark, org-agenda-bulk-unmark):
Move cursor to next visible line.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-beamer.el (org-beamer-sectioning): Leave columns environment
by specifying 0 or 1 for column width.
(org-beamer-column-widths): Make 0 stand for 0.0.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-mark-radio-links): Don't match inside
<<target>>.
* org.el (org-format-latex-header-extra): New variable.
(org-format-latex): Set org-format-latex-header-extra from
in-buffer stuff.
(org-format-latex): Add org-format-latex-header-extra to the
variables on which image creation depends.
(org-create-formula-image): Add the header stuff from in-buffer
settings.
(org-read-date-analyze): Base the analysis for future preference
on NOW, not on the default date.
* org-inlinetask.el (org-inlinetask-export-handler): Add CSS class
for TODO keyword in inline tasks.
* org.el (org-log-note-headings): New headings for removing
deadline or scheduling date.
(org-deadline, org-schedule): Arrange for logging when removing a
date.
(org-add-log-note): Handle deadline and scheduling removal.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-visible): Add LaTeX/pdf export.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-diary-class): New function.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-preprocess): Do process the text
of a radio target.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-entry-properties): Add TIMESTAMP properties back
in.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-all-time-keywords): New variable.
(org-set-regexps-and-options): Set `org-all-time-keywords'.
(org-entry-blocked-p): New function.
(org-special-properties): Add BLOCKED as a new special property.
(org-entry-properties): New optional argument SPECIFIC, only parse
for this property when it is specified.
(org-entry-get): Pass a SPECIFIC argument to
`org-entry-properties'.
* org-latex.el (org-export-as-latex): Preprocess TEXT as well.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-tables): No forced line end if
there is no caption.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-html-entities): Add Euro symbols from Marvosym
package.
* org-latex.el (org-export-latex-tables): Only add a caption when
macro in in longtable environments if one has been defined.
* org-html.el (org-export-as-html): Only take title from buffer if
not exporting body-only.
* org-latex.el (org-export-latex-preprocess): Better version of
the regular expression for protecting LaTeX macros.
(org-export-latex-preprocess): Start searching for macros to
protect from beginning of buffer.
* org-exp.el (org-export-target-internal-links): Check for
protectedness earlier in the string.
* org-agenda.el (org-agenda-highlight-todo): Match TODO keywords
case sensitively.
* org-id.el (org-id-store-link): Match TODO keywords case
sensitively.
* org.el (org-heading-components, org-get-outline-path)
(org-display-outline-path): Match TODO keywords case sensitively.
* org-latex.el (org-export-as-latex): Ignore read-only
properties.
* org-exp.el (org-export-preprocess-string): Remove any
`read-only' properties.
* org-agenda.el (org-agenda-inactive-leader): New option.
(org-agenda-get-timestamps): Use `org-agenda-inactive-leader'.
(org-tags-view): Prompt for matcher if MATCH is an empty string.
(org-todo-list): Prompt for matcher if ARG is an empty string.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-open-link-functions): New hook.
(org-open-at-point): Run `org-open-link-functions'.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-date-prompt): Allow inactive time
stamps as well.
* org.el (org-inhibit-startup-visibility-stuff): New variable.
(org-mode): Don't do startup visibility if inhibited.
(org-outline-overlay-data, org-set-outline-overlay-data): New
functions.
(org-save-outline-visibility): New macro.
(org-log-note-headings): Document that one should not change the
`state' note format.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-make-link-regexps): Capture link path into a group.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-beamer.el (org-beamer-after-initial-vars): Do not overwrite
the options plist.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-startup-with-beamer-mode): New option.
(org-property-changed-functions)
(org-property-allowed-value-functions): New hooks.
(org-entry-put, org-property-get-allowed-values): Run the new
hooks.
(org-property-next-allowed-value): Run the new hooks.
* org-exp.el (org-export-select-backend-specific-text): Add the
special beamer tags.
* org-beamer.el
(org-export-preprocess-before-selecting-backend-code-hook): New
file.
* org-latex.el (org-export-latex-after-initial-vars-hook): New hook.
(org-export-as-latex): Run
`org-export-latex-after-initial-vars-hook'.
(org-export-latex-format-toc-function)
(org-export-latex-make-header): Call
`org-export-latex-format-toc-function'.
* org.el (org-fill-template): Make template searches case sensitive.
* org-exp.el (org-export): Use "1" as a sign to export only the
subtree.
* org-colview-xemacs.el (org-columns-edit-value): Use
org-unrestricted property.
* org-colview.el (org-columns-edit-value): Use
org-unrestricted property.
* org.el (org-compute-property-at-point): Set org-unrestricted
text property if the list contains ":ETC".
(org-insert-property-drawer): Use
org-unrestricted property.
* org-exp.el
(org-export-preprocess-before-selecting-backend-code-hook): New hook.
(org-export-preprocess-string): Run
`org-export-preprocess-before-selecting-backend-code-hook'.
* org-xoxo.el (org-export-as-xoxo): Run `org-export-first-hook'.
* org-latex.el (org-export-region-as-latex): Run
`org-export-first-hook'.
* org-html.el (org-export-as-html): Run `org-export-first-hook'.
* org-docbook.el (org-export-as-docbook): Run
`org-export-first-hook'.
* org-ascii.el (org-export-as-ascii): Run `org-export-first-hook'.
* org-exp.el (org-export-first-hook): New hook.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-list.el (org-previous-item): Exit at the beginning of the
buffer.
* org-id.el (org-id-locations-save): Only write the id locations
if any are defined.
* org-archive.el (org-archive-all-done): Make this work in a file
with org-odd-levels-only set.
* org.el (org-get-refile-targets): Catch the case when a buffer
has no file.
* org-latex.el (org-export-as-latex): Cleanup forced line ends
where they are not needed.
(org-export-latex-subcontent): Remove unnecessary newlines.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-make-header): Remove \obeylines.
(org-export-latex-fontify): Fix regexp bug that takes special
care of protecting the right boundary characters in emphasis
matches.
(org-export-latex-preprocess): Allow multiple arguments to latex
macros.
* org.el (org-make-link-regexps): Use John Gruber's regexp for
urls.
* org-macs.el (org-re): Interpret :punct: in regexps.
* org-exp.el (org-export-replace-src-segments-and-examples): Also
take the final newline after the END line.
* org.el (org-clean-visibility-after-subtree-move): Only fix
entries that are not entirely invisible already.
(org-insert-link): Respect org-link-file-path-type for
"docview:" links in addition to "file:" links.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-format-source-code-or-example): Avoid
additional extra white lines in LaTeX.
* org-list.el (org-list-parse-list): Leave empty lines after the
list, don't consider them as part of the list.
* org-mobile.el (org-mobile-sumo-agenda-command): Allow tagstodo
searches.
* org-clock.el (org-clock-select-task): Convert integer to
character for XEmacs.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-resolve): Make reading a char XEmacs
compatible.
2010-04-10 Tassilo Horn <tassilo@member.fsf.org>
* org.el (org-complete-tags-always-offer-all-agenda-tags): New
variable.
(org-set-tags): Use it.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-list.el (org-empty-line-terminates-plain-lists): Update
docstring.
* org.el (org-format-latex): Fix link creation for processed latex
snippets.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-footnote.el (org-footnote-normalize): Protect replacement
text.
* org.el (org-inside-latex-macro-p): Save match data.
2010-04-10 Jan Bcker <jan.boecker@jboecker.de>
* org-docview.el: New file.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-class-options): New variable.
(org-export-latex-set-initial-vars): Use the class options.
* org.el (org-forward-same-level): Stop at headings that start
with an invisible character.
(org-additional-option-like-keywords): Add LaTeX_CLASS_OPTIONS.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-footnote.el (org-footnote-normalize): Don't take optional
arguments in LaTeX macros as footnotes.
* org.el (org-inside-latex-macro-p): New function.
* org-latex.el (org-latex-to-pdf-process): Change customization
group to `org-export-pdf'.
* org-agenda.el (org-agenda-get-blocks): Look at time string also
on days after the first one.
* org.el (org-insert-heading): Also check for item before assuming
before-first-heading condition.
* org-latex.el (org-latex-to-pdf-process): Fix typo in group tag.
(org-export-pdf-logfiles): New option.
(org-export-as-pdf): Use `org-export-pdf-logfiles'.
(org-export-pdf-logfiles): Fix customization type.
* org.el (org-insert-link): Improve error message when there is no
default link to select with RET.
* org-agenda.el (org-agenda-filter-by-tag): Use char argument from
parameter list.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-parse-global)
(org-export-latex-parse-content)
(org-export-latex-parse-subcontent): Use
`org-re-search-forward-unprotected'.
(org-export-as-pdf): Remove log files produced by XeTeX.
* org-macs.el (org-re-search-forward-unprotected): New function.
2010-04-10 James TD Smith <ahktenzero@mohorovi.cc>
* org-colview.el (org-agenda-colview-summarize): Sort out some
confusion between properties and titles, which resulted in
agenda summaries not working if a title was set for a column.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-mobile.el (org-mobile-agendas): New option.
(org-mobile-sumo-agenda-command): Select the right agendas.
* org-latex.el (org-export-latex-format-image): Preserve the
original-indentation property.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-insert-selection-line): Catch error when
an old tasks no longer exists.
* org-latex.el (org-export-as-pdf): Remove also the .idx file.
(org-export-as-pdf): Don't remove the old PDF file before making
the new one.
* org-mouse.el (org-mouse-end-headline, org-mouse-insert-item)
(org-mouse-context-menu): Use `org-looking-back'.
* org.el (org-cycle-level): Use `org-looking-back'.
* org-list.el (org-cycle-item-indentation): Use
`org-looking-back'.
* org-compat.el (org-looking-back): New function.
* org.el (org-insert-heading): Catch before-first-headline when
inserting a headline.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-format-image): Indent figure
environment, so that it does not interrupt plain list.
* org.el (org-open-at-point): Allow long link descriptions.
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-html.el (org-export-as-html): Remove empty lines at the
beginning of the exported text.
2010-04-15 Carsten Dominik <carsten.dominik@gmail.com>
* org.texi (LaTeX and PDF export): Add a footnote about xetex.
(LaTeX/PDF export commands): Section renamed and
moved.
(Sectioning structure): Update.
(References): New use case for field coordinates.
(The export dispatcher): Renamed from ASCII export.
(Setting up the staging area): Document the availability of
encryption for MobileOrg.
(Images and tables): Document how to reference labels.
(Index entries): New section.
(Generating an index): New section.
(Column width and alignment): Document that <N> now
means a fixed width, not a maximum width.
(Publishing options): Document the :email option.
(Beamer class export): Fix bug in the BEAMER example.
(Refiling notes): Document refile logging.
(In-buffer settings): Document refile logging keywords.
(Drawers): Document `C-c C-z' command.
(Agenda commands): Mention the alternative key `C-c C-z'.
(Special properties): Document the BLOCKED property.
(The spreadsheet): Mention the formula editor.
(References): Document field coordinates.
(Publishing action): Correct the documentation for the
publishing function.
(The date/time prompt): Document that we accept dates
like month/day/year.
(Cooperation): Document the changes in table.el support.
(Faces for TODO keywords, Faces for TODO keywords)
(Priorities): Document the easy colors.
(Visibility cycling): Document the new double prefix
arg for `org-reveal'.
(Cooperation): Remember.el is part of Emacs.
(Clean view): Mention that `wrap-prefix' is also set by
org-indent-mode.
(Agenda commands): Add information about prefix args to
scheduling and deadline commands.
(Search view): Point to the docstring of
`org-search-view' for more details.
(Agenda commands): Document that `>' prompts for a
date.
(Setting tags): Document variable
org-complete-tags-always-offer-all-agenda-tags.
(Column attributes): Cross-reference special
properties.
author | Carsten Dominik <carsten.dominik@gmail.com> |
---|---|
date | Thu, 15 Apr 2010 12:11:52 +0200 |
parents | 1d1d5d9bd884 |
children | a150e8a14679 |
comparison
equal
deleted
inserted
replaced
107862:d33170754d70 | 107863:594e81986a75 |
---|---|
2 ;; | 2 ;; |
3 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | 3 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
4 ;; | 4 ;; |
5 ;; Emacs Lisp Archive Entry | 5 ;; Emacs Lisp Archive Entry |
6 ;; Filename: org-latex.el | 6 ;; Filename: org-latex.el |
7 ;; Version: 6.33x | 7 ;; Version: 6.35i |
8 ;; Author: Bastien Guerry <bzg AT altern DOT org> | 8 ;; Author: Bastien Guerry <bzg AT altern DOT org> |
9 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com> | 9 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com> |
10 ;; Keywords: org, wp, tex | 10 ;; Keywords: org, wp, tex |
11 ;; Description: Converts an org-mode buffer into LaTeX | 11 ;; Description: Converts an org-mode buffer into LaTeX |
12 | 12 |
48 | 48 |
49 (require 'footnote) | 49 (require 'footnote) |
50 (require 'org) | 50 (require 'org) |
51 (require 'org-exp) | 51 (require 'org-exp) |
52 (require 'org-macs) | 52 (require 'org-macs) |
53 (require 'org-beamer) | |
53 | 54 |
54 ;;; Variables: | 55 ;;; Variables: |
55 (defvar org-export-latex-class nil) | 56 (defvar org-export-latex-class nil) |
57 (defvar org-export-latex-class-options nil) | |
56 (defvar org-export-latex-header nil) | 58 (defvar org-export-latex-header nil) |
57 (defvar org-export-latex-append-header nil) | 59 (defvar org-export-latex-append-header nil) |
58 (defvar org-export-latex-options-plist nil) | 60 (defvar org-export-latex-options-plist nil) |
59 (defvar org-export-latex-todo-keywords-1 nil) | 61 (defvar org-export-latex-todo-keywords-1 nil) |
60 (defvar org-export-latex-complex-heading-re nil) | 62 (defvar org-export-latex-complex-heading-re nil) |
87 :group 'org-export-latex | 89 :group 'org-export-latex |
88 :type '(string :tag "LaTeX class")) | 90 :type '(string :tag "LaTeX class")) |
89 | 91 |
90 (defcustom org-export-latex-classes | 92 (defcustom org-export-latex-classes |
91 '(("article" | 93 '(("article" |
92 "\\documentclass[11pt]{article} | 94 "\\documentclass[11pt]{article}" |
93 \\usepackage[utf8]{inputenc} | |
94 \\usepackage[T1]{fontenc} | |
95 \\usepackage{graphicx} | |
96 \\usepackage{longtable} | |
97 \\usepackage{float} | |
98 \\usepackage{wrapfig} | |
99 \\usepackage{soul} | |
100 \\usepackage{amssymb} | |
101 \\usepackage{hyperref}" | |
102 ("\\section{%s}" . "\\section*{%s}") | 95 ("\\section{%s}" . "\\section*{%s}") |
103 ("\\subsection{%s}" . "\\subsection*{%s}") | 96 ("\\subsection{%s}" . "\\subsection*{%s}") |
104 ("\\subsubsection{%s}" . "\\subsubsection*{%s}") | 97 ("\\subsubsection{%s}" . "\\subsubsection*{%s}") |
105 ("\\paragraph{%s}" . "\\paragraph*{%s}") | 98 ("\\paragraph{%s}" . "\\paragraph*{%s}") |
106 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) | 99 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) |
107 ("report" | 100 ("report" |
108 "\\documentclass[11pt]{report} | 101 "\\documentclass[11pt]{report}" |
109 \\usepackage[utf8]{inputenc} | |
110 \\usepackage[T1]{fontenc} | |
111 \\usepackage{graphicx} | |
112 \\usepackage{longtable} | |
113 \\usepackage{float} | |
114 \\usepackage{wrapfig} | |
115 \\usepackage{soul} | |
116 \\usepackage{amssymb} | |
117 \\usepackage{hyperref}" | |
118 ("\\part{%s}" . "\\part*{%s}") | 102 ("\\part{%s}" . "\\part*{%s}") |
119 ("\\chapter{%s}" . "\\chapter*{%s}") | 103 ("\\chapter{%s}" . "\\chapter*{%s}") |
120 ("\\section{%s}" . "\\section*{%s}") | 104 ("\\section{%s}" . "\\section*{%s}") |
121 ("\\subsection{%s}" . "\\subsection*{%s}") | 105 ("\\subsection{%s}" . "\\subsection*{%s}") |
122 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")) | 106 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")) |
123 ("book" | 107 ("book" |
124 "\\documentclass[11pt]{book} | 108 "\\documentclass[11pt]{book}" |
125 \\usepackage[utf8]{inputenc} | |
126 \\usepackage[T1]{fontenc} | |
127 \\usepackage{graphicx} | |
128 \\usepackage{longtable} | |
129 \\usepackage{float} | |
130 \\usepackage{wrapfig} | |
131 \\usepackage{soul} | |
132 \\usepackage{amssymb} | |
133 \\usepackage{hyperref}" | |
134 ("\\part{%s}" . "\\part*{%s}") | 109 ("\\part{%s}" . "\\part*{%s}") |
135 ("\\chapter{%s}" . "\\chapter*{%s}") | 110 ("\\chapter{%s}" . "\\chapter*{%s}") |
136 ("\\section{%s}" . "\\section*{%s}") | 111 ("\\section{%s}" . "\\section*{%s}") |
137 ("\\subsection{%s}" . "\\subsection*{%s}") | 112 ("\\subsection{%s}" . "\\subsection*{%s}") |
138 ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) | 113 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")) |
114 ("beamer" | |
115 "\\documentclass{beamer}" | |
116 org-beamer-sectioning | |
117 )) | |
139 "Alist of LaTeX classes and associated header and structure. | 118 "Alist of LaTeX classes and associated header and structure. |
140 If #+LaTeX_CLASS is set in the buffer, use its value and the | 119 If #+LaTeX_CLASS is set in the buffer, use its value and the |
141 associated information. Here is the structure of each cell: | 120 associated information. Here is the structure of each cell: |
142 | 121 |
143 \(class-name | 122 \(class-name |
144 header-string | 123 header-string |
145 (numbered-section . unnumbered-section\) | 124 (numbered-section . unnumbered-section\) |
146 ...\) | 125 ...\) |
147 | 126 |
148 A %s formatter is mandatory in each section string and will be | 127 The header string |
149 replaced by the title of the section. | 128 ----------------- |
129 | |
130 The HEADER-STRING is the header that will be inserted into the LaTeX file. | |
131 It should contain the \\documentclass macro, and anything else that is needed | |
132 for this setup. To this header, the following commands will be added: | |
133 | |
134 - Calls to \\usepackage for all packages mentioned in the variables | |
135 `org-export-latex-default-packages-alist' and | |
136 `org-export-latex-packages-alist'. Thus, your header definitions should | |
137 avoid to also request these packages. | |
138 | |
139 - Lines specified via \"#+LaTeX_HEADER:\" | |
140 | |
141 If you need more control about the sequence in which the header is built | |
142 up, or if you want to exclude one of these building blocks for a particular | |
143 class, you can use the following macro-like placeholders. | |
144 | |
145 [DEFAULT-PACKAGES] \\usepackage statements for default packages | |
146 [NO-DEFAULT-PACKAGES] do not include any of the default packages | |
147 [PACKAGES] \\usepackage statements for packages | |
148 [NO-PACKAGES] do not include the packages | |
149 [EXTRA] the stuff from #+LaTeX_HEADER | |
150 [NO-EXTRA] do not include #+LaTeX_HEADER stuff | |
151 | |
152 So a header like | |
153 | |
154 \\documentclass{article} | |
155 [NO-DEFAULT-PACKAGES] | |
156 [EXTRA] | |
157 \\providecommand{\\alert}[1]{\\textbf{#1}} | |
158 [PACKAGES] | |
159 | |
160 will omit the default packages, and will include the #+LaTeX_HEADER lines, | |
161 then have a call to \\providecommand, and then place \\usepackage commands | |
162 based on the content of `org-export-latex-packages-alist'. | |
163 | |
164 If your header or `org-export-latex-default-packages-alist' inserts | |
165 \"\\usepackage[AUTO]{inputenc}\", AUTO will automatically be replaced with | |
166 a coding system derived from `buffer-file-coding-system'. See also the | |
167 variable `org-export-latex-inputenc-alist' for a way to influence this | |
168 mechanism. | |
169 | |
170 The sectioning structure | |
171 ------------------------ | |
172 | |
173 The sectioning structure of the class is given by the elements following | |
174 the header string. For each sectioning level, a number of strings is | |
175 specified. A %s formatter is mandatory in each section string and will | |
176 be replaced by the title of the section. | |
150 | 177 |
151 Instead of a cons cell (numbered . unnumbered), you can also provide a list | 178 Instead of a cons cell (numbered . unnumbered), you can also provide a list |
152 of 2-4 elements, | 179 of 2 or 4 elements, |
153 | 180 |
154 (numbered-open numbered-close) | 181 (numbered-open numbered-close) |
155 | 182 |
156 or | 183 or |
157 | 184 |
158 (numbered-open numbered-close unnumbered-open unnumbered-close) | 185 (numbered-open numbered-close unnumbered-open unnumbered-close) |
159 | 186 |
160 providing opening and closing strings for an environment that should | 187 providing opening and closing strings for a LaTeX environment that should |
161 represent the document section. The opening clause should have a %s | 188 represent the document section. The opening clause should have a %s |
162 to represent the section title." | 189 to represent the section title. |
190 | |
191 Instead of a list of sectioning commands, you can also specify a | |
192 function name. That function will be called with two parameters, | |
193 the (reduced) level of the headline, and the headline text. The function | |
194 must return a cons cell with the (possibly modified) headline text, and the | |
195 sectioning list in the cdr." | |
163 :group 'org-export-latex | 196 :group 'org-export-latex |
164 :type '(repeat | 197 :type '(repeat |
165 (list (string :tag "LaTeX class") | 198 (list (string :tag "LaTeX class") |
166 (string :tag "LaTeX header") | 199 (string :tag "LaTeX header") |
167 (repeat :tag "Levels" :inline t | 200 (repeat :tag "Levels" :inline t |
168 (choice | 201 (choice |
169 (cons :tag "Heading" | 202 (cons :tag "Heading" |
170 (string :tag "numbered") | 203 (string :tag " numbered") |
171 (string :tag "unnumbered)")) | 204 (string :tag "unnumbered")) |
172 (list :tag "Environment" | 205 (list :tag "Environment" |
173 (string :tag "Opening (numbered) ") | 206 (string :tag "Opening (numbered)") |
174 (string :tag "Closing (numbered) ") | 207 (string :tag "Closing (numbered)") |
175 (string :tag "Opening (unnumbered)") | 208 (string :tag "Opening (unnumbered)") |
176 (string :tag "Closing (unnumbered)"))))))) | 209 (string :tag "Closing (unnumbered)")) |
210 (function :tag "Hook computing sectioning")))))) | |
211 | |
212 (defcustom org-export-latex-inputenc-alist nil | |
213 "Alist of inputenc coding system names, and what should really be used. | |
214 For example, adding an entry | |
215 | |
216 (\"utf8\" . \"utf8x\") | |
217 | |
218 will cause \\usepackage[utf8x]{inputenc} to be used for buffers that | |
219 are written as utf8 files." | |
220 :group 'org-export-latex | |
221 :type '(repeat | |
222 (cons | |
223 (string :tag "Derived from buffer") | |
224 (string :tag "Use this instead")))) | |
225 | |
177 | 226 |
178 (defcustom org-export-latex-emphasis-alist | 227 (defcustom org-export-latex-emphasis-alist |
179 '(("*" "\\textbf{%s}" nil) | 228 '(("*" "\\textbf{%s}" nil) |
180 ("/" "\\emph{%s}" nil) | 229 ("/" "\\emph{%s}" nil) |
181 ("_" "\\underline{%s}" nil) | 230 ("_" "\\underline{%s}" nil) |
238 (defcustom org-export-latex-timestamp-keyword-markup "\\texttt{%s}" | 287 (defcustom org-export-latex-timestamp-keyword-markup "\\texttt{%s}" |
239 "A printf format string to be applied to time stamps." | 288 "A printf format string to be applied to time stamps." |
240 :group 'org-export-latex | 289 :group 'org-export-latex |
241 :type 'string) | 290 :type 'string) |
242 | 291 |
292 (defcustom org-export-latex-hyperref-format "\\href{%s}{%s}" | |
293 "A printf format string to be applied to hyperref links. | |
294 The format must contain two %s instances. The first will be filled with | |
295 the link, the second with the link description." | |
296 :group 'org-export-latex | |
297 :type 'string) | |
298 | |
243 (defcustom org-export-latex-tables-verbatim nil | 299 (defcustom org-export-latex-tables-verbatim nil |
244 "When non-nil, tables are exported verbatim." | 300 "When non-nil, tables are exported verbatim." |
245 :group 'org-export-latex | 301 :group 'org-export-latex |
246 :type 'boolean) | 302 :type 'boolean) |
247 | 303 |
303 :group 'org-export-latex | 359 :group 'org-export-latex |
304 :type '(cons (string :tag "Open") | 360 :type '(cons (string :tag "Open") |
305 (string :tag "Close"))) | 361 (string :tag "Close"))) |
306 | 362 |
307 (defcustom org-export-latex-listings nil | 363 (defcustom org-export-latex-listings nil |
308 "Non-nil means, export source code using the listings package. | 364 "Non-nil means export source code using the listings package. |
309 This package will fontify source code, possibly even with color. | 365 This package will fontify source code, possibly even with color. |
310 If you want to use this, you also need to make LaTeX use the | 366 If you want to use this, you also need to make LaTeX use the |
311 listings package, and if you want to have color, the color | 367 listings package, and if you want to have color, the color |
312 package. Just add these to `org-export-latex-packages-alist', | 368 package. Just add these to `org-export-latex-packages-alist', |
313 for example using customize, or with something like | 369 for example using customize, or with something like |
374 :group 'org-export-latex | 430 :group 'org-export-latex |
375 :type 'coding-system) | 431 :type 'coding-system) |
376 | 432 |
377 (defgroup org-export-pdf nil | 433 (defgroup org-export-pdf nil |
378 "Options for exporting Org-mode files to PDF, via LaTeX." | 434 "Options for exporting Org-mode files to PDF, via LaTeX." |
379 :tag "Org Export LaTeX" | 435 :tag "Org Export PDF" |
380 :group 'org-export-latex | 436 :group 'org-export-latex |
381 :group 'org-export) | 437 :group 'org-export) |
382 | 438 |
383 (defcustom org-latex-to-pdf-process | 439 (defcustom org-latex-to-pdf-process |
384 '("pdflatex -interaction nonstopmode %s" | 440 '("pdflatex -interaction nonstopmode %s" |
393 result, and it also does not do any error checking. | 449 result, and it also does not do any error checking. |
394 | 450 |
395 Alternatively, this may be a Lisp function that does the processing, so you | 451 Alternatively, this may be a Lisp function that does the processing, so you |
396 could use this to apply the machinery of AUCTeX or the Emacs LaTeX mode. | 452 could use this to apply the machinery of AUCTeX or the Emacs LaTeX mode. |
397 This function should accept the file name as its single argument." | 453 This function should accept the file name as its single argument." |
398 :group 'org-export-latex | 454 :group 'org-export-pdf |
399 :type '(choice (repeat :tag "Shell command sequence" | 455 :type '(choice (repeat :tag "Shell command sequence" |
400 (string :tag "Shell command")) | 456 (string :tag "Shell command")) |
401 (function))) | 457 (function))) |
402 | 458 |
459 (defcustom org-export-pdf-logfiles | |
460 '("aux" "idx" "log" "out" "toc" "nav" "snm" "vrb") | |
461 "The list of file extensions to consider as LaTeX logfiles." | |
462 :group 'org-export-pdf | |
463 :type '(repeat (string :tag "Extension"))) | |
464 | |
403 (defcustom org-export-pdf-remove-logfiles t | 465 (defcustom org-export-pdf-remove-logfiles t |
404 "Non-nil means, remove the logfiles produced by PDF production. | 466 "Non-nil means remove the logfiles produced by PDF production. |
405 These are the .aux, .log, .out, and .toc files." | 467 These are the .aux, .log, .out, and .toc files." |
406 :group 'org-export-pdf | 468 :group 'org-export-pdf |
407 :type 'boolean) | 469 :type 'boolean) |
408 | 470 |
409 ;;; Hooks | 471 ;;; Hooks |
410 | 472 |
473 (defvar org-export-latex-after-initial-vars-hook nil | |
474 "Hook run before LaTeX export. | |
475 The exact moment is after the initial variables like org-export-latex-class | |
476 have been determined from the environment.") | |
477 | |
411 (defvar org-export-latex-after-blockquotes-hook nil | 478 (defvar org-export-latex-after-blockquotes-hook nil |
412 "Hook run during LaTeX export, after blockquote, verse, center are done.") | 479 "Hook run during LaTeX export, after blockquote, verse, center are done.") |
413 | 480 |
414 (defvar org-export-latex-final-hook nil | 481 (defvar org-export-latex-final-hook nil |
415 "Hook run in the finalized LaTeX buffer.") | 482 "Hook run in the finalized LaTeX buffer.") |
483 | |
484 (defvar org-export-latex-after-save-hook nil | |
485 "Hook run in the finalized LaTeX buffer, after it has been saved.") | |
416 | 486 |
417 ;;; Autoload functions: | 487 ;;; Autoload functions: |
418 | 488 |
419 ;;;###autoload | 489 ;;;###autoload |
420 (defun org-export-as-latex-batch () | 490 (defun org-export-as-latex-batch () |
512 When BODY-ONLY is set, don't produce the file header and footer, | 582 When BODY-ONLY is set, don't produce the file header and footer, |
513 simply return the content of \begin{document}...\end{document}, | 583 simply return the content of \begin{document}...\end{document}, |
514 without even the \begin{document} and \end{document} commands. | 584 without even the \begin{document} and \end{document} commands. |
515 when PUB-DIR is set, use this as the publishing directory." | 585 when PUB-DIR is set, use this as the publishing directory." |
516 (interactive "P") | 586 (interactive "P") |
587 (run-hooks 'org-export-first-hook) | |
588 | |
517 ;; Make sure we have a file name when we need it. | 589 ;; Make sure we have a file name when we need it. |
518 (when (and (not (or to-buffer body-only)) | 590 (when (and (not (or to-buffer body-only)) |
519 (not buffer-file-name)) | 591 (not buffer-file-name)) |
520 (if (buffer-base-buffer) | 592 (if (buffer-base-buffer) |
521 (org-set-local 'buffer-file-name | 593 (org-set-local 'buffer-file-name |
523 buffer-file-name)) | 595 buffer-file-name)) |
524 (error "Need a file name to be able to export"))) | 596 (error "Need a file name to be able to export"))) |
525 | 597 |
526 (message "Exporting to LaTeX...") | 598 (message "Exporting to LaTeX...") |
527 (org-unmodified | 599 (org-unmodified |
528 (remove-text-properties (point-min) (point-max) | 600 (let ((inhibit-read-only t)) |
529 '(:org-license-to-kill nil))) | 601 (remove-text-properties (point-min) (point-max) |
602 '(:org-license-to-kill nil)))) | |
530 (org-update-radio-target-regexp) | 603 (org-update-radio-target-regexp) |
531 (org-export-latex-set-initial-vars ext-plist arg) | 604 (org-export-latex-set-initial-vars ext-plist arg) |
605 (setq org-export-opt-plist org-export-latex-options-plist) | |
606 (org-install-letbind) | |
607 (run-hooks 'org-export-latex-after-initial-vars-hook) | |
532 (let* ((wcf (current-window-configuration)) | 608 (let* ((wcf (current-window-configuration)) |
533 (opt-plist org-export-latex-options-plist) | 609 (opt-plist org-export-latex-options-plist) |
534 (region-p (org-region-active-p)) | 610 (region-p (org-region-active-p)) |
535 (rbeg (and region-p (region-beginning))) | 611 (rbeg (and region-p (region-beginning))) |
536 (rend (and region-p (region-end))) | 612 (rend (and region-p (region-end))) |
545 (opt-plist (setq org-export-opt-plist | 621 (opt-plist (setq org-export-opt-plist |
546 (if subtree-p | 622 (if subtree-p |
547 (org-export-add-subtree-options opt-plist rbeg) | 623 (org-export-add-subtree-options opt-plist rbeg) |
548 opt-plist))) | 624 opt-plist))) |
549 ;; Make sure the variable contains the updated values. | 625 ;; Make sure the variable contains the updated values. |
550 (org-export-latex-options-plist opt-plist) | 626 (org-export-latex-options-plist (setq org-export-opt-plist opt-plist)) |
627 ;; The following two are dynamically scoped into other | |
628 ;; routines below. | |
629 (org-current-export-dir | |
630 (or pub-dir (org-export-directory :html opt-plist))) | |
631 (org-current-export-file buffer-file-name) | |
551 (title (or (and subtree-p (org-export-get-title-from-subtree)) | 632 (title (or (and subtree-p (org-export-get-title-from-subtree)) |
552 (plist-get opt-plist :title) | 633 (plist-get opt-plist :title) |
553 (and (not | 634 (and (not |
554 (plist-get opt-plist :skip-before-1st-heading)) | 635 (plist-get opt-plist :skip-before-1st-heading)) |
555 (org-export-grab-title-from-buffer)) | 636 (org-export-grab-title-from-buffer)) |
556 (file-name-sans-extension | 637 (and buffer-file-name |
557 (file-name-nondirectory buffer-file-name)))) | 638 (file-name-sans-extension |
558 (filename (concat (file-name-as-directory | 639 (file-name-nondirectory buffer-file-name))) |
559 (or pub-dir | 640 "No Title")) |
560 (org-export-directory :LaTeX ext-plist))) | 641 (filename |
561 (file-name-sans-extension | 642 (and (not to-buffer) |
562 (or (and subtree-p | 643 (concat |
563 (org-entry-get rbeg "EXPORT_FILE_NAME" t)) | 644 (file-name-as-directory |
564 (file-name-nondirectory ;sans-extension | 645 (or pub-dir |
565 buffer-file-name))) | 646 (org-export-directory :LaTeX ext-plist))) |
566 ".tex")) | 647 (file-name-sans-extension |
567 (filename (if (equal (file-truename filename) | 648 (or (and subtree-p |
568 (file-truename buffer-file-name)) | 649 (org-entry-get rbeg "EXPORT_FILE_NAME" t)) |
569 (concat filename ".tex") | 650 (file-name-nondirectory ;sans-extension |
570 filename)) | 651 (or buffer-file-name |
652 (error "Don't know which export file to use."))))) | |
653 ".tex"))) | |
654 (filename | |
655 (and filename | |
656 (if (equal (file-truename filename) | |
657 (file-truename (or buffer-file-name "dummy.org"))) | |
658 (concat filename ".tex") | |
659 filename))) | |
571 (buffer (if to-buffer | 660 (buffer (if to-buffer |
572 (cond | 661 (cond |
573 ((eq to-buffer 'string) (get-buffer-create | 662 ((eq to-buffer 'string) (get-buffer-create |
574 "*Org LaTeX Export*")) | 663 "*Org LaTeX Export*")) |
575 (t (get-buffer-create to-buffer))) | 664 (t (get-buffer-create to-buffer))) |
600 (save-buffer-coding-system (or org-export-latex-coding-system | 689 (save-buffer-coding-system (or org-export-latex-coding-system |
601 coding-system)) | 690 coding-system)) |
602 (region (buffer-substring | 691 (region (buffer-substring |
603 (if region-p (region-beginning) (point-min)) | 692 (if region-p (region-beginning) (point-min)) |
604 (if region-p (region-end) (point-max)))) | 693 (if region-p (region-end) (point-max)))) |
694 (text | |
695 (and text (string-match "\\S-" text) | |
696 (org-export-preprocess-string | |
697 text | |
698 :emph-multiline t | |
699 :for-LaTeX t | |
700 :comments nil | |
701 :tags (plist-get opt-plist :tags) | |
702 :priority (plist-get opt-plist :priority) | |
703 :footnotes (plist-get opt-plist :footnotes) | |
704 :drawers (plist-get opt-plist :drawers) | |
705 :timestamps (plist-get opt-plist :timestamps) | |
706 :todo-keywords (plist-get opt-plist :todo-keywords) | |
707 :add-text nil | |
708 :skip-before-1st-heading skip | |
709 :select-tags nil | |
710 :exclude-tags nil | |
711 :LaTeX-fragments nil))) | |
605 (string-for-export | 712 (string-for-export |
606 (org-export-preprocess-string | 713 (org-export-preprocess-string |
607 region | 714 region |
608 :emph-multiline t | 715 :emph-multiline t |
609 :for-LaTeX t | 716 :for-LaTeX t |
654 (org-export-latex-parse-global level odd))))) | 761 (org-export-latex-parse-global level odd))))) |
655 | 762 |
656 ;; finalization | 763 ;; finalization |
657 (unless body-only (insert "\n\\end{document}")) | 764 (unless body-only (insert "\n\\end{document}")) |
658 | 765 |
766 ;; Attach description terms to the \item macro | |
767 (goto-char (point-min)) | |
768 (while (re-search-forward "^[ \t]*\\\\item\\([ \t]+\\)\\[" nil t) | |
769 (delete-region (match-beginning 1) (match-end 1))) | |
770 | |
659 ;; Relocate the table of contents | 771 ;; Relocate the table of contents |
660 (goto-char (point-min)) | 772 (goto-char (point-min)) |
661 (when (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t) | 773 (when (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t) |
662 (goto-char (point-min)) | 774 (goto-char (point-min)) |
663 (while (re-search-forward "\\\\tableofcontents\\>[ \t]*\n?" nil t) | 775 (while (re-search-forward "\\\\tableofcontents\\>[ \t]*\n?" nil t) |
664 (replace-match "")) | 776 (replace-match "")) |
665 (goto-char (point-min)) | 777 (goto-char (point-min)) |
666 (and (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t) | 778 (and (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t) |
667 (replace-match "\\tableofcontents" t t))) | 779 (replace-match "\\tableofcontents" t t))) |
668 | 780 |
781 ;; Cleanup forced line ends in items where they are not needed | |
782 (goto-char (point-min)) | |
783 (while (re-search-forward | |
784 "^[ \t]*\\\\item\\>.*\\(\\\\\\\\\\)[ \t]*\\(\n\\\\label.*\\)*\n\\\\begin" | |
785 nil t) | |
786 (delete-region (match-beginning 1) (match-end 1))) | |
787 (goto-char (point-min)) | |
788 (while (re-search-forward | |
789 "^[ \t]*\\\\item\\>.*\\(\\\\\\\\\\)[ \t]*\\(\n\\\\label.*\\)*" | |
790 nil t) | |
791 (if (looking-at "[\n \t]+") | |
792 (replace-match "\n"))) | |
793 | |
669 (run-hooks 'org-export-latex-final-hook) | 794 (run-hooks 'org-export-latex-final-hook) |
670 (or to-buffer (save-buffer)) | 795 (or to-buffer (save-buffer)) |
796 (org-export-latex-fix-inputenc) | |
797 (run-hooks 'org-export-latex-after-save-hook) | |
671 (goto-char (point-min)) | 798 (goto-char (point-min)) |
672 (or (org-export-push-to-kill-ring "LaTeX") | 799 (or (org-export-push-to-kill-ring "LaTeX") |
673 (message "Exporting to LaTeX...done")) | 800 (message "Exporting to LaTeX...done")) |
674 (prog1 | 801 (prog1 |
675 (if (eq to-buffer 'string) | 802 (if (eq to-buffer 'string) |
696 (save-excursion | 823 (save-excursion |
697 (goto-char (point-min)) | 824 (goto-char (point-min)) |
698 (re-search-forward "\\\\bibliography{" nil t)))) | 825 (re-search-forward "\\\\bibliography{" nil t)))) |
699 cmd) | 826 cmd) |
700 (with-current-buffer outbuf (erase-buffer)) | 827 (with-current-buffer outbuf (erase-buffer)) |
701 (and (file-exists-p pdffile) (delete-file pdffile)) | |
702 (message "Processing LaTeX file...") | 828 (message "Processing LaTeX file...") |
703 (if (and cmds (symbolp cmds)) | 829 (if (and cmds (symbolp cmds)) |
704 (funcall cmds file) | 830 (funcall cmds file) |
705 (while cmds | 831 (while cmds |
706 (setq cmd (pop cmds)) | 832 (setq cmd (pop cmds)) |
718 (message "Processing LaTeX file...done") | 844 (message "Processing LaTeX file...done") |
719 (if (not (file-exists-p pdffile)) | 845 (if (not (file-exists-p pdffile)) |
720 (error "PDF file was not produced") | 846 (error "PDF file was not produced") |
721 (set-window-configuration wconfig) | 847 (set-window-configuration wconfig) |
722 (when org-export-pdf-remove-logfiles | 848 (when org-export-pdf-remove-logfiles |
723 (dolist (ext '("aux" "log" "out" "toc")) | 849 (dolist (ext org-export-pdf-logfiles) |
724 (setq file (concat base "." ext)) | 850 (setq file (concat base "." ext)) |
725 (and (file-exists-p file) (delete-file file)))) | 851 (and (file-exists-p file) (delete-file file)))) |
726 (message "Exporting to PDF...done") | 852 (message "Exporting to PDF...done") |
727 pdffile))) | 853 pdffile))) |
728 | 854 |
730 (defun org-export-as-pdf-and-open (arg) | 856 (defun org-export-as-pdf-and-open (arg) |
731 "Export as LaTeX, then process through to PDF, and open." | 857 "Export as LaTeX, then process through to PDF, and open." |
732 (interactive "P") | 858 (interactive "P") |
733 (let ((pdffile (org-export-as-pdf arg))) | 859 (let ((pdffile (org-export-as-pdf arg))) |
734 (if pdffile | 860 (if pdffile |
735 (org-open-file pdffile) | 861 (progn |
862 (org-open-file pdffile) | |
863 (when org-export-kill-product-buffer-when-displayed | |
864 (kill-buffer (find-buffer-visiting | |
865 (concat (file-name-sans-extension (buffer-file-name)) | |
866 ".tex"))))) | |
736 (error "PDF file was not produced")))) | 867 (error "PDF file was not produced")))) |
737 | 868 |
738 ;;; Parsing functions: | 869 ;;; Parsing functions: |
739 | 870 |
740 (defun org-export-latex-parse-global (level odd) | 871 (defun org-export-latex-parse-global (level odd) |
743 Return a list reflecting the document structure." | 874 Return a list reflecting the document structure." |
744 (save-excursion | 875 (save-excursion |
745 (goto-char (point-min)) | 876 (goto-char (point-min)) |
746 (let* ((cnt 0) output | 877 (let* ((cnt 0) output |
747 (depth org-export-latex-sectioning-depth)) | 878 (depth org-export-latex-sectioning-depth)) |
748 (while (re-search-forward | 879 (while (org-re-search-forward-unprotected |
749 (concat "^\\(\\(?:\\*\\)\\{" | 880 (concat "^\\(\\(?:\\*\\)\\{" |
750 (number-to-string (+ (if odd 2 1) level)) | 881 (number-to-string (+ (if odd 2 1) level)) |
751 "\\}\\) \\(.*\\)$") | 882 "\\}\\) \\(.*\\)$") |
752 ;; make sure that there is no upper heading | 883 ;; make sure that there is no upper heading |
753 (when (> level 0) | 884 (when (> level 0) |
754 (save-excursion | 885 (save-excursion |
755 (save-match-data | 886 (save-match-data |
756 (re-search-forward | 887 (org-re-search-forward-unprotected |
757 (concat "^\\(\\(?:\\*\\)\\{" | 888 (concat "^\\(\\(?:\\*\\)\\{" |
758 (number-to-string level) | 889 (number-to-string level) |
759 "\\}\\) \\(.*\\)$") nil t)))) t) | 890 "\\}\\) \\(.*\\)$") nil t)))) t) |
760 (setq cnt (1+ cnt)) | 891 (setq cnt (1+ cnt)) |
761 (let* ((pos (match-beginning 0)) | 892 (let* ((pos (match-beginning 0)) |
763 (nlevel (if odd (/ (+ 3 level) 2) (1+ level)))) | 894 (nlevel (if odd (/ (+ 3 level) 2) (1+ level)))) |
764 (save-excursion | 895 (save-excursion |
765 (narrow-to-region | 896 (narrow-to-region |
766 (point) | 897 (point) |
767 (save-match-data | 898 (save-match-data |
768 (if (re-search-forward | 899 (if (org-re-search-forward-unprotected |
769 (concat "^\\(\\(?:\\*\\)\\{" | 900 (concat "^\\(\\(?:\\*\\)\\{" |
770 (number-to-string (+ (if odd 2 1) level)) | 901 (number-to-string (+ (if odd 2 1) level)) |
771 "\\}\\) \\(.*\\)$") nil t) | 902 "\\}\\) \\(.*\\)$") nil t) |
772 (match-beginning 0) | 903 (match-beginning 0) |
773 (point-max)))) | 904 (point-max)))) |
787 (list output)))) | 918 (list output)))) |
788 | 919 |
789 (defun org-export-latex-parse-content () | 920 (defun org-export-latex-parse-content () |
790 "Extract the content of a section." | 921 "Extract the content of a section." |
791 (let ((beg (point)) | 922 (let ((beg (point)) |
792 (end (if (re-search-forward "^\\(\\*\\)+ .*$" nil t) | 923 (end (if (org-re-search-forward-unprotected "^\\(\\*\\)+ .*$" nil t) |
793 (progn (beginning-of-line) (point)) | 924 (progn (beginning-of-line) (point)) |
794 (point-max)))) | 925 (point-max)))) |
795 (buffer-substring beg end))) | 926 (buffer-substring beg end))) |
796 | 927 |
797 (defun org-export-latex-parse-subcontent (level odd) | 928 (defun org-export-latex-parse-subcontent (level odd) |
798 "Extract the subcontent of a section at LEVEL. | 929 "Extract the subcontent of a section at LEVEL. |
799 If ODD Is non-nil, assume subcontent only contains odd sections." | 930 If ODD Is non-nil, assume subcontent only contains odd sections." |
800 (if (not (re-search-forward | 931 (if (not (org-re-search-forward-unprotected |
801 (concat "^\\(\\(?:\\*\\)\\{" | 932 (concat "^\\(\\(?:\\*\\)\\{" |
802 (number-to-string (+ (if odd 4 2) level)) | 933 (number-to-string (+ (if odd 4 2) level)) |
803 "\\}\\) \\(.*\\)$") | 934 "\\}\\) \\(.*\\)$") |
804 nil t)) | 935 nil t)) |
805 nil ; subcontent is nil | 936 nil ; subcontent is nil |
822 (mapc (lambda(x) (org-export-latex-subcontent x num)) subcontent))) | 953 (mapc (lambda(x) (org-export-latex-subcontent x num)) subcontent))) |
823 | 954 |
824 (defun org-export-latex-subcontent (subcontent num) | 955 (defun org-export-latex-subcontent (subcontent num) |
825 "Export each cell of SUBCONTENT to LaTeX. | 956 "Export each cell of SUBCONTENT to LaTeX. |
826 If NUM, export sections as numerical sections." | 957 If NUM, export sections as numerical sections." |
827 (let* ((heading (org-export-latex-fontify-headline | 958 (let* ((heading (cdr (assoc 'heading subcontent))) |
828 (cdr (assoc 'heading subcontent)))) | |
829 (level (- (cdr (assoc 'level subcontent)) | 959 (level (- (cdr (assoc 'level subcontent)) |
830 org-export-latex-add-level)) | 960 org-export-latex-add-level)) |
831 (occur (number-to-string (cdr (assoc 'occur subcontent)))) | 961 (occur (number-to-string (cdr (assoc 'occur subcontent)))) |
832 (content (cdr (assoc 'content subcontent))) | 962 (content (cdr (assoc 'content subcontent))) |
833 (subcontent (cadr (assoc 'subcontent subcontent))) | 963 (subcontent (cadr (assoc 'subcontent subcontent))) |
834 (label (org-get-text-property-any 0 'target heading)) | 964 (label (org-get-text-property-any 0 'target heading)) |
835 (label-list (cons label (cdr (assoc label | 965 (label-list (cons label (cdr (assoc label |
836 org-export-target-aliases))))) | 966 org-export-target-aliases)))) |
967 (sectioning org-export-latex-sectioning) | |
968 (depth org-export-latex-sectioning-depth) | |
969 main-heading sub-heading) | |
970 (when (symbolp (car sectioning)) | |
971 (setq sectioning (funcall (car sectioning) level heading)) | |
972 (when sectioning | |
973 (setq heading (car sectioning) | |
974 sectioning (cdr sectioning) | |
975 ;; target property migh have changed... | |
976 label (org-get-text-property-any 0 'target heading) | |
977 label-list (cons label (cdr (assoc label | |
978 org-export-target-aliases))))) | |
979 (if sectioning (setq sectioning (make-list 10 sectioning))) | |
980 (setq depth (if sectioning 10000 0))) | |
981 (if (string-match "[ \t]*\\\\\\\\[ \t]*" heading) | |
982 (setq main-heading (substring heading 0 (match-beginning 0)) | |
983 sub-heading (substring heading (match-end 0)))) | |
984 (setq heading (org-export-latex-fontify-headline heading) | |
985 sub-heading (and sub-heading | |
986 (org-export-latex-fontify-headline sub-heading)) | |
987 main-heading (and main-heading | |
988 (org-export-latex-fontify-headline main-heading))) | |
837 (cond | 989 (cond |
838 ;; Normal conversion | 990 ;; Normal conversion |
839 ((<= level org-export-latex-sectioning-depth) | 991 ((<= level depth) |
840 (let* ((sec (nth (1- level) org-export-latex-sectioning)) | 992 (let* ((sec (nth (1- level) sectioning)) |
841 start end) | 993 start end) |
842 (if (consp (cdr sec)) | 994 (if (consp (cdr sec)) |
843 (setq start (nth (if num 0 2) sec) | 995 (setq start (nth (if num 0 2) sec) |
844 end (nth (if num 1 3) sec)) | 996 end (nth (if num 1 3) sec)) |
845 (setq start (if num (car sec) (cdr sec)))) | 997 (setq start (if num (car sec) (cdr sec)))) |
846 (insert (format start heading) "\n") | 998 (insert (format start (if main-heading main-heading heading) |
999 (or sub-heading ""))) | |
1000 (insert "\n") | |
847 (when label | 1001 (when label |
848 (insert (mapconcat (lambda (l) (format "\\label{%s}" l)) | 1002 (insert (mapconcat (lambda (l) (format "\\label{%s}" l)) |
849 label-list "\n") "\n")) | 1003 label-list "\n") "\n")) |
850 (insert (org-export-latex-content content)) | 1004 (insert (org-export-latex-content content)) |
851 (cond ((stringp subcontent) (insert subcontent)) | 1005 (cond ((stringp subcontent) (insert subcontent)) |
852 ((listp subcontent) (org-export-latex-sub subcontent))) | 1006 ((listp subcontent) |
853 (if end (insert end "\n")))) | 1007 (while (org-looking-back "\n\n") (backward-delete-char 1)) |
1008 (org-export-latex-sub subcontent))) | |
1009 (when (and end (string-match "[^ \t]" end)) | |
1010 (let ((hook (org-get-text-property-any 0 'org-insert-hook end))) | |
1011 (and (functionp hook) (funcall hook))) | |
1012 (insert end "\n")))) | |
854 ;; At a level under the hl option: we can drop this subsection | 1013 ;; At a level under the hl option: we can drop this subsection |
855 ((> level org-export-latex-sectioning-depth) | 1014 ((> level depth) |
856 (cond ((eq org-export-latex-low-levels 'description) | 1015 (cond ((eq org-export-latex-low-levels 'description) |
857 (if (string-match "% ends low level$" | 1016 (if (string-match "% ends low level$" |
858 (buffer-substring (point-at-bol 0) (point))) | 1017 (buffer-substring (point-at-bol 0) (point))) |
859 (delete-region (point-at-bol 0) (point)) | 1018 (delete-region (point-at-bol 0) (point)) |
860 (insert "\\begin{description}\n")) | 1019 (insert "\\begin{description}\n")) |
861 (insert (format "\n\\item[%s]%s~\n\n" | 1020 (insert (format "\n\\item[%s]%s~\n" |
862 heading | 1021 heading |
863 (if label (format "\\label{%s}" label) ""))) | 1022 (if label (format "\\label{%s}" label) ""))) |
864 (insert (org-export-latex-content content)) | 1023 (insert (org-export-latex-content content)) |
865 (cond ((stringp subcontent) (insert subcontent)) | 1024 (cond ((stringp subcontent) (insert subcontent)) |
866 ((listp subcontent) (org-export-latex-sub subcontent))) | 1025 ((listp subcontent) (org-export-latex-sub subcontent))) |
869 (if (string-match "% ends low level$" | 1028 (if (string-match "% ends low level$" |
870 (buffer-substring (point-at-bol 0) (point))) | 1029 (buffer-substring (point-at-bol 0) (point))) |
871 (delete-region (point-at-bol 0) (point)) | 1030 (delete-region (point-at-bol 0) (point)) |
872 (insert (format "\\begin{%s}\n" | 1031 (insert (format "\\begin{%s}\n" |
873 (symbol-name org-export-latex-low-levels)))) | 1032 (symbol-name org-export-latex-low-levels)))) |
874 (insert (format "\n\\item %s\\\\\n%s\n" | 1033 (insert (format "\n\\item %s\\\\\n%s%%" |
875 heading | 1034 heading |
876 (if label (format "\\label{%s}" label) ""))) | 1035 (if label (format "\\label{%s}" label) ""))) |
877 (insert (org-export-latex-content content)) | 1036 (insert (org-export-latex-content content)) |
878 (cond ((stringp subcontent) (insert subcontent)) | 1037 (cond ((stringp subcontent) (insert subcontent)) |
879 ((listp subcontent) (org-export-latex-sub subcontent))) | 1038 ((listp subcontent) (org-export-latex-sub subcontent))) |
928 (goto-char (point-min)) | 1087 (goto-char (point-min)) |
929 (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\([a-zA-Z]+\\)" nil t) | 1088 (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\([a-zA-Z]+\\)" nil t) |
930 (match-string 1)))) | 1089 (match-string 1)))) |
931 (plist-get org-export-latex-options-plist :latex-class) | 1090 (plist-get org-export-latex-options-plist :latex-class) |
932 org-export-latex-default-class) | 1091 org-export-latex-default-class) |
1092 org-export-latex-class-options | |
1093 (or (and (org-region-active-p) | |
1094 (save-excursion | |
1095 (goto-char (region-beginning)) | |
1096 (and (looking-at org-complex-heading-regexp) | |
1097 (org-entry-get nil "LaTeX_CLASS_OPTIONS" 'selective)))) | |
1098 (save-excursion | |
1099 (save-restriction | |
1100 (widen) | |
1101 (goto-char (point-min)) | |
1102 (and (re-search-forward "^#\\+LaTeX_CLASS_OPTIONS:[ \t]*\\(.*?\\)[ \t]*$" nil t) | |
1103 (match-string 1)))) | |
1104 (plist-get org-export-latex-options-plist :latex-class-options)) | |
933 org-export-latex-class | 1105 org-export-latex-class |
934 (or (car (assoc org-export-latex-class org-export-latex-classes)) | 1106 (or (car (assoc org-export-latex-class org-export-latex-classes)) |
935 (error "No definition for class `%s' in `org-export-latex-classes'" | 1107 (error "No definition for class `%s' in `org-export-latex-classes'" |
936 org-export-latex-class)) | 1108 org-export-latex-class)) |
937 org-export-latex-header | 1109 org-export-latex-header |
941 org-export-latex-sectioning-depth | 1113 org-export-latex-sectioning-depth |
942 (or level | 1114 (or level |
943 (let ((hl-levels | 1115 (let ((hl-levels |
944 (plist-get org-export-latex-options-plist :headline-levels)) | 1116 (plist-get org-export-latex-options-plist :headline-levels)) |
945 (sec-depth (length org-export-latex-sectioning))) | 1117 (sec-depth (length org-export-latex-sectioning))) |
946 (if (> hl-levels sec-depth) sec-depth hl-levels))))) | 1118 (if (> hl-levels sec-depth) sec-depth hl-levels)))) |
1119 (when (and org-export-latex-class-options | |
1120 (string-match "\\S-" org-export-latex-class-options) | |
1121 (string-match "^[ \t]*\\(\\\\documentclass\\)\\(\\[.*?\\]\\)?" | |
1122 org-export-latex-header)) | |
1123 (setq org-export-latex-header | |
1124 (concat (substring org-export-latex-header 0 (match-end 1)) | |
1125 org-export-latex-class-options | |
1126 (substring org-export-latex-header (match-end 0)))))) | |
1127 | |
1128 (defvar org-export-latex-format-toc-function | |
1129 'org-export-latex-format-toc-default | |
1130 "The function formatting returning the string to createthe table of contents. | |
1131 The function mus take one parameter, the depth of the table of contents.") | |
947 | 1132 |
948 (defun org-export-latex-make-header (title opt-plist) | 1133 (defun org-export-latex-make-header (title opt-plist) |
949 "Make the LaTeX header and return it as a string. | 1134 "Make the LaTeX header and return it as a string. |
950 TITLE is the current title from the buffer or region. | 1135 TITLE is the current title from the buffer or region. |
951 OPT-PLIST is the options plist for current buffer." | 1136 OPT-PLIST is the options plist for current buffer." |
952 (let ((toc (plist-get opt-plist :table-of-contents)) | 1137 (let ((toc (plist-get opt-plist :table-of-contents)) |
953 (author (plist-get opt-plist :author))) | 1138 (author (org-export-apply-macros-in-string |
1139 (plist-get opt-plist :author)))) | |
954 (concat | 1140 (concat |
955 (if (plist-get opt-plist :time-stamp-file) | 1141 (if (plist-get opt-plist :time-stamp-file) |
956 (format-time-string "%% Created %Y-%m-%d %a %H:%M\n")) | 1142 (format-time-string "%% Created %Y-%m-%d %a %H:%M\n")) |
957 ;; insert LaTeX custom header | 1143 ;; insert LaTeX custom header and packages from the list |
958 (org-export-apply-macros-in-string org-export-latex-header) | 1144 (org-splice-latex-header |
959 "\n" | 1145 (org-export-apply-macros-in-string org-export-latex-header) |
960 ;; insert information on LaTeX packages | 1146 org-export-latex-default-packages-alist |
961 (when org-export-latex-packages-alist | 1147 org-export-latex-packages-alist |
962 (mapconcat (lambda(p) | 1148 (org-export-apply-macros-in-string |
963 (if (equal "" (car p)) | 1149 (plist-get opt-plist :latex-header-extra))) |
964 (format "\\usepackage{%s}" (cadr p)) | 1150 ;; append another special variable |
965 (format "\\usepackage[%s]{%s}" | |
966 (car p) (cadr p)))) | |
967 org-export-latex-packages-alist "\n")) | |
968 ;; insert additional commands in the header | |
969 (org-export-apply-macros-in-string | |
970 (plist-get opt-plist :latex-header-extra)) | |
971 (org-export-apply-macros-in-string org-export-latex-append-header) | 1151 (org-export-apply-macros-in-string org-export-latex-append-header) |
1152 ;; define align if not yet defined | |
1153 "\n\\providecommand{\\alert}[1]{\\textbf{#1}}" | |
972 ;; insert the title | 1154 ;; insert the title |
973 (format | 1155 (format |
974 "\n\n\\title{%s}\n" | 1156 "\n\n\\title{%s}\n" |
975 ;; convert the title | 1157 ;; convert the title |
976 (org-export-latex-content | 1158 (org-export-latex-content |
978 ;; insert author info | 1160 ;; insert author info |
979 (if (plist-get opt-plist :author-info) | 1161 (if (plist-get opt-plist :author-info) |
980 (format "\\author{%s}\n" | 1162 (format "\\author{%s}\n" |
981 (org-export-latex-fontify-headline (or author user-full-name))) | 1163 (org-export-latex-fontify-headline (or author user-full-name))) |
982 (format "%%\\author{%s}\n" | 1164 (format "%%\\author{%s}\n" |
983 (or author user-full-name))) | 1165 (org-export-latex-fontify-headline (or author user-full-name)))) |
984 ;; insert the date | 1166 ;; insert the date |
985 (format "\\date{%s}\n" | 1167 (format "\\date{%s}\n" |
986 (format-time-string | 1168 (format-time-string |
987 (or (plist-get opt-plist :date) | 1169 (or (plist-get opt-plist :date) |
988 org-export-latex-date-format))) | 1170 org-export-latex-date-format))) |
995 org-export-latex-title-command)) | 1177 org-export-latex-title-command)) |
996 "\n\n" | 1178 "\n\n" |
997 ;; table of contents | 1179 ;; table of contents |
998 (when (and org-export-with-toc | 1180 (when (and org-export-with-toc |
999 (plist-get opt-plist :section-numbers)) | 1181 (plist-get opt-plist :section-numbers)) |
1000 (cond ((numberp toc) | 1182 (funcall org-export-latex-format-toc-function |
1001 (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n" | 1183 (cond ((numberp toc) |
1002 (min toc (plist-get opt-plist :headline-levels)))) | 1184 (min toc (plist-get opt-plist :headline-levels))) |
1003 (toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n" | 1185 (toc (plist-get opt-plist :headline-levels)))))))) |
1004 (plist-get opt-plist :headline-levels))))) | 1186 |
1005 (when (plist-get opt-plist :preserve-breaks) | 1187 (defun org-export-latex-format-toc-default (depth) |
1006 "\\obeylines\n")))) | 1188 (when depth |
1189 (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n" | |
1190 depth))) | |
1007 | 1191 |
1008 (defun org-export-latex-first-lines (opt-plist &optional beg end) | 1192 (defun org-export-latex-first-lines (opt-plist &optional beg end) |
1009 "Export the first lines before first headline. | 1193 "Export the first lines before first headline. |
1010 If BEG is non-nil, it is the beginning of the region. | 1194 If BEG is non-nil, it is the beginning of the region. |
1011 If END is non-nil, it is the end of the region." | 1195 If END is non-nil, it is the end of the region." |
1026 :skip-before-1st-heading nil | 1210 :skip-before-1st-heading nil |
1027 :LaTeX-fragments nil | 1211 :LaTeX-fragments nil |
1028 :timestamps (plist-get opt-plist :timestamps) | 1212 :timestamps (plist-get opt-plist :timestamps) |
1029 :footnotes (plist-get opt-plist :footnotes))) | 1213 :footnotes (plist-get opt-plist :footnotes))) |
1030 (org-unmodified | 1214 (org-unmodified |
1031 (add-text-properties pt (max pt (1- end)) | 1215 (let ((inhibit-read-only t)) |
1032 '(:org-license-to-kill t))))))) | 1216 (add-text-properties pt (max pt (1- end)) |
1217 '(:org-license-to-kill t)))))))) | |
1033 | 1218 |
1034 (defvar org-export-latex-header-defs nil | 1219 (defvar org-export-latex-header-defs nil |
1035 "The header definitions that might be used in the LaTeX body.") | 1220 "The header definitions that might be used in the LaTeX body.") |
1036 (defvar org-export-latex-header-defs-re nil | 1221 (defvar org-export-latex-header-defs-re nil |
1037 "The header definitions that might be used in the LaTeX body.") | 1222 "The header definitions that might be used in the LaTeX body.") |
1125 (with-temp-buffer | 1310 (with-temp-buffer |
1126 ;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at | 1311 ;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at |
1127 ;; the beginning of the buffer - inserting "\n" is safe here though. | 1312 ;; the beginning of the buffer - inserting "\n" is safe here though. |
1128 (insert "\n" string) | 1313 (insert "\n" string) |
1129 (goto-char (point-min)) | 1314 (goto-char (point-min)) |
1130 (let ((re (concat "\\\\[a-zA-Z]+\\(?:" | 1315 (let ((re (concat "\\\\\\([a-zA-Z]+\\)" |
1131 "\\[.*\\]" | 1316 "\\(?:<[^<>\n]*>\\)*" |
1132 "\\)?" | 1317 "\\(?:\\[[^][\n]*?\\]\\)*" |
1133 (org-create-multibrace-regexp "{" "}" 3)))) | 1318 "\\(?:<[^<>\n]*>\\)*" |
1319 "\\(" | |
1320 (org-create-multibrace-regexp "{" "}" 3) | |
1321 "\\)\\{1,3\\}"))) | |
1134 (while (re-search-forward re nil t) | 1322 (while (re-search-forward re nil t) |
1135 (unless (save-excursion (goto-char (match-beginning 0)) | 1323 (unless (or |
1136 (equal (char-after (point-at-bol)) ?#)) | 1324 ;; check for comment line |
1325 (save-excursion (goto-char (match-beginning 0)) | |
1326 (equal (char-after (point-at-bol)) ?#)) | |
1327 ;; Check if this is a defined entity, so that is may need conversion | |
1328 (org-entity-get (match-string 1))) | |
1137 (add-text-properties (match-beginning 0) (match-end 0) | 1329 (add-text-properties (match-beginning 0) (match-end 0) |
1138 '(org-protected t))))) | 1330 '(org-protected t))))) |
1139 (when (plist-get org-export-latex-options-plist :emphasize) | 1331 (when (plist-get org-export-latex-options-plist :emphasize) |
1140 (org-export-latex-fontify)) | 1332 (org-export-latex-fontify)) |
1141 (org-export-latex-keywords-maybe) | 1333 (org-export-latex-keywords-maybe) |
1190 (replace-match "\\$" t t))) | 1382 (replace-match "\\$" t t))) |
1191 ((member (match-string 2) '("&" "%" "#")) | 1383 ((member (match-string 2) '("&" "%" "#")) |
1192 (if (equal (match-string 1) "\\") | 1384 (if (equal (match-string 1) "\\") |
1193 (replace-match (match-string 2) t t) | 1385 (replace-match (match-string 2) t t) |
1194 (replace-match (concat (match-string 1) "\\" | 1386 (replace-match (concat (match-string 1) "\\" |
1195 (match-string 2)) t t))) | 1387 (match-string 2)) t t) |
1388 (backward-char 1))) | |
1196 ((equal (match-string 2) "...") | 1389 ((equal (match-string 2) "...") |
1197 (replace-match | 1390 (replace-match |
1198 (concat (match-string 1) | 1391 (concat (match-string 1) |
1199 (org-export-latex-protect-string "\\ldots{}")) t t)) | 1392 (org-export-latex-protect-string "\\ldots{}")) t t)) |
1200 ((equal (match-string 2) "~") | 1393 ((equal (match-string 2) "~") |
1214 (cond ((equal (match-string 2) "\\") | 1407 (cond ((equal (match-string 2) "\\") |
1215 (replace-match (or (save-match-data | 1408 (replace-match (or (save-match-data |
1216 (org-export-latex-treat-backslash-char | 1409 (org-export-latex-treat-backslash-char |
1217 (match-string 1) | 1410 (match-string 1) |
1218 (or (match-string 3) ""))) | 1411 (or (match-string 3) ""))) |
1219 "") t t)) | 1412 "") t t) |
1413 (when (and (get-text-property (1- (point)) 'org-entity) | |
1414 (looking-at "{}")) | |
1415 ;; OK, this was an entity replacement, and the user | |
1416 ;; had terminated the entity with {}. Make sure | |
1417 ;; {} is protected as well, and remove the extra {} | |
1418 ;; inserted by the conversion. | |
1419 (put-text-property (point) (+ 2 (point)) 'org-protected t) | |
1420 (if (save-excursion (goto-char (max (- (point) 2) (point-min))) | |
1421 (looking-at "{}")) | |
1422 (replace-match "")) | |
1423 (forward-char 2)) | |
1424 (backward-char 1)) | |
1220 ((member (match-string 2) '("_" "^")) | 1425 ((member (match-string 2) '("_" "^")) |
1221 (replace-match (or (save-match-data | 1426 (replace-match (or (save-match-data |
1222 (org-export-latex-treat-sub-super-char | 1427 (org-export-latex-treat-sub-super-char |
1223 sub-superscript | 1428 sub-superscript |
1224 (match-string 2) | 1429 (match-string 2) |
1225 (match-string 1) | 1430 (match-string 1) |
1226 (match-string 3))) "") t t) | 1431 (match-string 3))) "") t t) |
1227 (backward-char 1))))))) | 1432 (backward-char 1))))))) |
1228 '(;"^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$" | 1433 '(;"^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$" |
1229 "\\(\\(\\\\?\\$\\)\\)" | 1434 "\\(\\(\\\\?\\$\\)\\)" |
1230 "\\([a-za-z0-9]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\({[^{}]+}\\|[a-za-z0-9]+\\|[ \t\n]\\|[:punct:]\\|)\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)" | 1435 "\\([a-zA-Z0-9()]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\({[^{}]+}\\|[a-zA-Z0-9]+\\|[ \t\n]\\|[:punct:]\\|)\\|{[a-zA-Z0-9]+}\\|([a-zA-Z0-9]+)\\)" |
1231 "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|[a-zA-Z&#%{}\"]+\\)" | 1436 "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|\\([&#%{}\"]\\|[a-zA-Z][a-zA-Z0-9]*\\)\\)" |
1232 "\\(.\\|^\\)\\(&\\)" | 1437 "\\(.\\|^\\)\\(&\\)" |
1233 "\\(.\\|^\\)\\(#\\)" | 1438 "\\(.\\|^\\)\\(#\\)" |
1234 "\\(.\\|^\\)\\(%\\)" | 1439 "\\(.\\|^\\)\\(%\\)" |
1235 "\\(.\\|^\\)\\({\\)" | 1440 "\\(.\\|^\\)\\({\\)" |
1236 "\\(.\\|^\\)\\(}\\)" | 1441 "\\(.\\|^\\)\\(}\\)" |
1278 (concat string-before "\\" char "{}" string-after))))) | 1483 (concat string-before "\\" char "{}" string-after))))) |
1279 | 1484 |
1280 (defun org-export-latex-treat-backslash-char (string-before string-after) | 1485 (defun org-export-latex-treat-backslash-char (string-before string-after) |
1281 "Convert the \"$\" special character to LaTeX. | 1486 "Convert the \"$\" special character to LaTeX. |
1282 The conversion is made depending of STRING-BEFORE and STRING-AFTER." | 1487 The conversion is made depending of STRING-BEFORE and STRING-AFTER." |
1283 (cond ((member (list string-after) org-html-entities) | 1488 (let ((ass (org-entity-get string-after))) |
1284 ;; backslash is part of a special entity (like "\alpha") | 1489 (cond |
1285 (concat string-before "$\\" | 1490 (ass (org-add-props |
1286 (or (cdar (member (list string-after) org-html-entities)) | 1491 (if (nth 2 ass) |
1287 string-after) "$")) | 1492 (concat string-before |
1288 ((and (not (string-match "^[ \n\t]" string-after)) | 1493 (org-export-latex-protect-string |
1289 (not (string-match "[ \t]\\'\\|^" string-before))) | 1494 (concat "$" (nth 1 ass) "$"))) |
1290 ;; backslash is inside a word | 1495 (concat string-before (org-export-latex-protect-string |
1291 (org-export-latex-protect-string | 1496 (nth 1 ass)))) |
1292 (concat string-before "\\textbackslash{}" string-after))) | 1497 nil 'org-entity t)) |
1293 ((not (or (equal string-after "") | 1498 ((and (not (string-match "^[ \n\t]" string-after)) |
1294 (string-match "^[ \t\n]" string-after))) | 1499 (not (string-match "[ \t]\\'\\|^" string-before))) |
1295 ;; backslash might escape a character (like \#) or a user TeX | 1500 ;; backslash is inside a word |
1296 ;; macro (like \setcounter) | 1501 (concat string-before |
1297 (org-export-latex-protect-string | 1502 (org-export-latex-protect-string |
1298 (concat string-before "\\" string-after))) | 1503 (concat "\\textbackslash{}" string-after)))) |
1299 ((and (string-match "^[ \t\n]" string-after) | 1504 ((not (or (equal string-after "") |
1300 (string-match "[ \t\n]\\'" string-before)) | 1505 (string-match "^[ \t\n]" string-after))) |
1301 ;; backslash is alone, convert it to $\backslash$ | 1506 ;; backslash might escape a character (like \#) or a user TeX |
1302 (org-export-latex-protect-string | 1507 ;; macro (like \setcounter) |
1303 (concat string-before "\\textbackslash{}" string-after))) | 1508 (concat string-before |
1304 (t (org-export-latex-protect-string | 1509 (org-export-latex-protect-string (concat "\\" string-after)))) |
1305 (concat string-before "\\textbackslash{}" string-after))))) | 1510 ((and (string-match "^[ \t\n]" string-after) |
1511 (string-match "[ \t\n]\\'" string-before)) | |
1512 ;; backslash is alone, convert it to $\backslash$ | |
1513 (org-export-latex-protect-string | |
1514 (concat string-before "\\textbackslash{}" string-after))) | |
1515 (t (org-export-latex-protect-string | |
1516 (concat string-before "\\textbackslash{}" string-after)))))) | |
1306 | 1517 |
1307 (defun org-export-latex-keywords () | 1518 (defun org-export-latex-keywords () |
1308 "Convert special keywords to LaTeX." | 1519 "Convert special keywords to LaTeX." |
1309 (goto-char (point-min)) | 1520 (goto-char (point-min)) |
1310 (while (re-search-forward org-export-latex-special-keyword-regexp nil t) | 1521 (while (re-search-forward org-export-latex-special-keyword-regexp nil t) |
1311 (replace-match (format org-export-latex-timestamp-keyword-markup | 1522 (replace-match (format org-export-latex-timestamp-keyword-markup |
1312 (match-string 0)) t t) | 1523 (match-string 0)) t t) |
1313 (save-excursion | 1524 (save-excursion |
1314 (beginning-of-line 1) | 1525 (beginning-of-line 1) |
1315 (unless (looking-at ".*\\\\newline[ \t]*$") | 1526 (unless (looking-at ".*\n[ \t]*\n") |
1316 (end-of-line 1) | 1527 (end-of-line 1) |
1317 (insert "\\newline"))))) | 1528 (insert "\n"))))) |
1318 | 1529 |
1319 (defun org-export-latex-fixed-width (opt) | 1530 (defun org-export-latex-fixed-width (opt) |
1320 "When OPT is non-nil convert fixed-width sections to LaTeX." | 1531 "When OPT is non-nil convert fixed-width sections to LaTeX." |
1321 (goto-char (point-min)) | 1532 (goto-char (point-min)) |
1322 (while (re-search-forward "^[ \t]*:\\([ \t]\\|$\\)" nil t) | 1533 (while (re-search-forward "^[ \t]*:\\([ \t]\\|$\\)" nil t) |
1338 (defvar org-table-last-alignment) ; defined in org-table.el | 1549 (defvar org-table-last-alignment) ; defined in org-table.el |
1339 (defvar org-table-last-column-widths) ; defined in org-table.el | 1550 (defvar org-table-last-column-widths) ; defined in org-table.el |
1340 (declare-function orgtbl-to-latex "org-table" (table params) t) | 1551 (declare-function orgtbl-to-latex "org-table" (table params) t) |
1341 (defun org-export-latex-tables (insert) | 1552 (defun org-export-latex-tables (insert) |
1342 "Convert tables to LaTeX and INSERT it." | 1553 "Convert tables to LaTeX and INSERT it." |
1554 ;; First, get the table.el tables | |
1555 (goto-char (point-min)) | |
1556 (while (re-search-forward "^[ \t]*\\(\\+-[-+]*\\+\\)[ \t]*\n[ \t]*|" nil t) | |
1557 (org-if-unprotected | |
1558 (require 'table) | |
1559 (org-export-latex-convert-table.el-table))) | |
1560 | |
1561 ;; And now the Org-mode tables | |
1343 (goto-char (point-min)) | 1562 (goto-char (point-min)) |
1344 (while (re-search-forward "^\\([ \t]*\\)|" nil t) | 1563 (while (re-search-forward "^\\([ \t]*\\)|" nil t) |
1345 (org-if-unprotected-at (1- (point)) | 1564 (org-if-unprotected-at (1- (point)) |
1346 (org-table-align) | 1565 (org-table-align) |
1347 (let* ((beg (org-table-begin)) | 1566 (let* ((beg (org-table-begin)) |
1368 (string-match "\\<longtable\\>" attr)) | 1587 (string-match "\\<longtable\\>" attr)) |
1369 align (and attr (stringp attr) | 1588 align (and attr (stringp attr) |
1370 (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr) | 1589 (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr) |
1371 (match-string 1 attr)) | 1590 (match-string 1 attr)) |
1372 floatp (or caption label)) | 1591 floatp (or caption label)) |
1592 (setq caption (and caption (org-export-latex-fontify-headline caption))) | |
1373 (setq lines (org-split-string raw-table "\n")) | 1593 (setq lines (org-split-string raw-table "\n")) |
1374 (apply 'delete-region (list beg end)) | 1594 (apply 'delete-region (list beg end)) |
1375 (when org-export-table-remove-special-lines | 1595 (when org-export-table-remove-special-lines |
1376 (setq lines (org-table-clean-before-export lines 'maybe-quoted))) | 1596 (setq lines (org-table-clean-before-export lines 'maybe-quoted))) |
1377 (when org-table-clean-did-remove-column | 1597 (when org-table-clean-did-remove-column |
1422 (insert (org-export-latex-protect-string | 1642 (insert (org-export-latex-protect-string |
1423 (concat | 1643 (concat |
1424 (if longtblp | 1644 (if longtblp |
1425 (concat "\\begin{longtable}{" align "}\n") | 1645 (concat "\\begin{longtable}{" align "}\n") |
1426 (if floatp "\\begin{table}[htb]\n")) | 1646 (if floatp "\\begin{table}[htb]\n")) |
1427 (if (or floatp longtblp) | 1647 (if floatp |
1428 (format | 1648 (format |
1429 "\\caption{%s%s}" | 1649 "\\caption{%s%s}" |
1430 (if label (concat "\\\label{" label "}") "") | 1650 (if label (concat "\\\label{" label "}") "") |
1431 (or caption ""))) | 1651 (or caption ""))) |
1432 (if longtblp "\\\\\n" "\n") | 1652 (if (and longtblp caption) "\\\\\n" "\n") |
1433 (if (and org-export-latex-tables-centered (not longtblp)) | 1653 (if (and org-export-latex-tables-centered (not longtblp)) |
1434 "\\begin{center}\n") | 1654 "\\begin{center}\n") |
1435 (if (not longtblp) (concat "\\begin{tabular}{" align "}\n")) | 1655 (if (not longtblp) (concat "\\begin{tabular}{" align "}\n")) |
1436 (orgtbl-to-latex | 1656 (orgtbl-to-latex |
1437 lines | 1657 lines |
1450 (if longtblp | 1670 (if longtblp |
1451 "\\end{longtable}" | 1671 "\\end{longtable}" |
1452 (if floatp "\\end{table}")))) | 1672 (if floatp "\\end{table}")))) |
1453 "\n\n")))))))) | 1673 "\n\n")))))))) |
1454 | 1674 |
1675 (defun org-export-latex-convert-table.el-table () | |
1676 "Replace table.el table at point with LaTeX code." | |
1677 (let (tbl caption label line floatp attr align rmlines) | |
1678 (setq line (buffer-substring (point-at-bol) (point-at-eol)) | |
1679 label (org-get-text-property-any 0 'org-label line) | |
1680 caption (org-get-text-property-any 0 'org-caption line) | |
1681 attr (org-get-text-property-any 0 'org-attributes line) | |
1682 align (and attr (stringp attr) | |
1683 (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr) | |
1684 (match-string 1 attr)) | |
1685 rmlines (and attr (stringp attr) | |
1686 (string-match "\\<rmlines\\>" attr)) | |
1687 floatp (or label caption)) | |
1688 (and (get-buffer "*org-export-table*") | |
1689 (kill-buffer (get-buffer "*org-export-table*"))) | |
1690 (table-generate-source 'latex "*org-export-table*" "caption") | |
1691 (setq tbl (with-current-buffer "*org-export-table*" | |
1692 (buffer-string))) | |
1693 (while (string-match "^%.*\n" tbl) | |
1694 (setq tbl (replace-match "" t t tbl))) | |
1695 ;; fix the hlines | |
1696 (when rmlines | |
1697 (let ((n 0) lines) | |
1698 (setq lines (mapcar (lambda (x) | |
1699 (if (string-match "^\\\\hline$" x) | |
1700 (progn | |
1701 (setq n (1+ n)) | |
1702 (if (= n 2) x nil)) | |
1703 x)) | |
1704 (org-split-string tbl "\n"))) | |
1705 (setq tbl (mapconcat 'identity (delq nil lines) "\n")))) | |
1706 (when (and align (string-match "\\\\begin{tabular}{.*}" tbl)) | |
1707 (setq tbl (replace-match (concat "\\begin{tabular}{" align "}") | |
1708 t t tbl))) | |
1709 (and (get-buffer "*org-export-table*") | |
1710 (kill-buffer (get-buffer "*org-export-table*"))) | |
1711 (beginning-of-line 0) | |
1712 (while (looking-at "[ \t]*\\(|\\|\\+-\\)") | |
1713 (delete-region (point) (1+ (point-at-eol)))) | |
1714 (when org-export-latex-tables-centered | |
1715 (setq tbl (concat "\\begin{center}\n" tbl "\\end{center}"))) | |
1716 (when floatp | |
1717 (setq tbl (concat "\\begin{table}\n" | |
1718 (format "\\caption{%s%s}\n" | |
1719 (if label (format "\\label{%s}" label) "") | |
1720 (or caption "")) | |
1721 tbl | |
1722 "\n\\end{table}\n"))) | |
1723 (insert (org-export-latex-protect-string tbl)))) | |
1724 | |
1455 (defun org-export-latex-fontify () | 1725 (defun org-export-latex-fontify () |
1456 "Convert fontification to LaTeX." | 1726 "Convert fontification to LaTeX." |
1457 (goto-char (point-min)) | 1727 (goto-char (point-min)) |
1458 (while (re-search-forward org-emph-re nil t) | 1728 (while (re-search-forward org-emph-re nil t) |
1459 ;; The match goes one char after the *string*, except at the end of a line | 1729 ;; The match goes one char after the *string*, except at the end of a line |
1471 (save-excursion | 1741 (save-excursion |
1472 (goto-char (match-beginning 1)) | 1742 (goto-char (match-beginning 1)) |
1473 (save-match-data | 1743 (save-match-data |
1474 (and (org-at-table-p) | 1744 (and (org-at-table-p) |
1475 (string-match | 1745 (string-match |
1476 "[|\n]" (buffer-substring beg end)))))) | 1746 "[|\n]" (buffer-substring beg end))))) |
1747 (and (equal (match-string 3) "+") | |
1748 (save-match-data | |
1749 (string-match "\\`-+\\'" (match-string 4))))) | |
1477 (setq s (match-string 4)) | 1750 (setq s (match-string 4)) |
1478 (setq rpl (concat (match-string 1) | 1751 (setq rpl (concat (match-string 1) |
1479 (org-export-latex-emph-format (cadr emph) | 1752 (org-export-latex-emph-format (cadr emph) |
1480 (match-string 4)) | 1753 (match-string 4)) |
1481 (match-string 5))) | 1754 (match-string 5))) |
1482 (if (caddr emph) | 1755 (if (caddr emph) |
1483 (setq rpl (org-export-latex-protect-string rpl)) | 1756 (setq rpl (org-export-latex-protect-string rpl)) |
1484 (save-match-data | 1757 (save-match-data |
1485 (if (string-match "\\`.\\(\\\\[a-z]+{\\)\\(.*\\)\\(}\\).?\\'" rpl) | 1758 (if (string-match "\\`.?\\(\\\\[a-z]+{\\)\\(.*\\)\\(}\\).?\\'" rpl) |
1486 (progn | 1759 (progn |
1487 (add-text-properties (match-beginning 1) (match-end 1) | 1760 (add-text-properties (match-beginning 1) (match-end 1) |
1488 '(org-protected t) rpl) | 1761 '(org-protected t) rpl) |
1489 (add-text-properties (match-beginning 3) (match-end 3) | 1762 (add-text-properties (match-beginning 3) (match-end 3) |
1490 '(org-protected t) rpl))))) | 1763 '(org-protected t) rpl))))) |
1571 (concat type "://" (org-export-directory | 1844 (concat type "://" (org-export-directory |
1572 :LaTeX org-export-latex-options-plist) | 1845 :LaTeX org-export-latex-options-plist) |
1573 raw-path)))))))) | 1846 raw-path)))))))) |
1574 ;; process with link inserting | 1847 ;; process with link inserting |
1575 (apply 'delete-region remove) | 1848 (apply 'delete-region remove) |
1849 (setq caption (and caption (org-export-latex-fontify-headline caption))) | |
1576 (cond ((and imgp | 1850 (cond ((and imgp |
1577 (plist-get org-export-latex-options-plist :inline-images)) | 1851 (plist-get org-export-latex-options-plist :inline-images)) |
1578 ;; OK, we need to inline an image | 1852 ;; OK, we need to inline an image |
1579 (insert | 1853 (insert |
1580 (org-export-latex-format-image raw-path caption label attr))) | 1854 (org-export-latex-format-image raw-path caption label attr))) |
1587 ((not type) | 1861 ((not type) |
1588 (insert (format "\\hyperref[%s]{%s}" | 1862 (insert (format "\\hyperref[%s]{%s}" |
1589 (org-remove-initial-hash | 1863 (org-remove-initial-hash |
1590 (org-solidify-link-text raw-path)) | 1864 (org-solidify-link-text raw-path)) |
1591 desc))) | 1865 desc))) |
1592 (path | 1866 (path |
1593 (when (org-at-table-p) | 1867 (when (org-at-table-p) |
1594 ;; There is a strange problem when we have a link in a table, | 1868 ;; There is a strange problem when we have a link in a table, |
1595 ;; ampersands then cause a problem. I think this must be | 1869 ;; ampersands then cause a problem. I think this must be |
1596 ;; a LaTeX issue, but we here implement a work-around anyway. | 1870 ;; a LaTeX issue, but we here implement a work-around anyway. |
1597 (setq path (org-export-latex-protect-amp path) | 1871 (setq path (org-export-latex-protect-amp path) |
1598 desc (org-export-latex-protect-amp desc))) | 1872 desc (org-export-latex-protect-amp desc))) |
1599 (insert (format "\\href{%s}{%s}" path desc))) | 1873 (insert (format org-export-latex-hyperref-format path desc))) |
1600 (t (insert "\\texttt{" desc "}"))))))) | 1874 (t (insert "\\texttt{" desc "}"))))))) |
1601 | 1875 |
1602 | 1876 |
1603 (defun org-export-latex-format-image (path caption label attr) | 1877 (defun org-export-latex-format-image (path caption label attr) |
1604 "Format the image element, depending on user settings." | 1878 "Format the image element, depending on user settings." |
1605 (let (floatp wrapp placement figenv) | 1879 (let (ind floatp wrapp placement figenv) |
1606 (setq floatp (or caption label)) | 1880 (setq floatp (or caption label)) |
1881 (setq ind (org-get-text-property-any 0 'original-indentation path)) | |
1607 (when (and attr (stringp attr)) | 1882 (when (and attr (stringp attr)) |
1608 (if (string-match "[ \t]*\\<wrap\\>" attr) | 1883 (if (string-match "[ \t]*\\<wrap\\>" attr) |
1609 (setq wrapp t floatp nil attr (replace-match "" t t attr))) | 1884 (setq wrapp t floatp nil attr (replace-match "" t t attr))) |
1610 (if (string-match "[ \t]*\\<float\\>" attr) | 1885 (if (string-match "[ \t]*\\<float\\>" attr) |
1611 (setq wrapp nil floatp t attr (replace-match "" t t attr)))) | 1886 (setq wrapp nil floatp t attr (replace-match "" t t attr)))) |
1612 | 1887 |
1613 (setq placement | 1888 (setq placement |
1614 (cond | 1889 (cond |
1615 (wrapp "{l}{0.5\\textwidth}") | 1890 (wrapp "{l}{0.5\\textwidth}") |
1616 (floatp "[htb]") | 1891 (floatp "[htb]") |
1617 (t ""))) | 1892 (t ""))) |
1637 \\includegraphics[%attr]{%path} | 1912 \\includegraphics[%attr]{%path} |
1638 \\caption{%labelcmd%caption} | 1913 \\caption{%labelcmd%caption} |
1639 \\end{figure}") | 1914 \\end{figure}") |
1640 (t "\\includegraphics[%attr]{%path}"))) | 1915 (t "\\includegraphics[%attr]{%path}"))) |
1641 | 1916 |
1917 | |
1918 (setq figenv (mapconcat 'identity (split-string figenv "\n") | |
1919 (save-excursion (beginning-of-line 1) | |
1920 (looking-at "[ \t]*") | |
1921 (concat "\n" (match-string 0))))) | |
1922 | |
1642 (if (and (not label) (not caption) | 1923 (if (and (not label) (not caption) |
1643 (string-match "^\\\\caption{.*\n" figenv)) | 1924 (string-match "^\\\\caption{.*\n" figenv)) |
1644 (setq figenv (replace-match "" t t figenv))) | 1925 (setq figenv (replace-match "" t t figenv))) |
1645 (org-fill-template | 1926 (org-add-props |
1646 figenv | 1927 (org-fill-template |
1647 (list (cons "path" | 1928 figenv |
1648 (if (file-name-absolute-p path) | 1929 (list (cons "path" |
1649 (expand-file-name path) | 1930 (if (file-name-absolute-p path) |
1650 path)) | 1931 (expand-file-name path) |
1651 (cons "attr" attr) | 1932 path)) |
1652 (cons "labelcmd" (if label (format "\\label{%s}" | 1933 (cons "attr" attr) |
1653 label)"")) | 1934 (cons "labelcmd" (if label (format "\\label{%s}" |
1654 (cons "caption" (or caption "")) | 1935 label)"")) |
1655 (cons "placement" (or placement "")))))) | 1936 (cons "caption" (or caption "")) |
1937 (cons "placement" (or placement "")))) | |
1938 nil 'original-indentation ind))) | |
1656 | 1939 |
1657 (defun org-export-latex-protect-amp (s) | 1940 (defun org-export-latex-protect-amp (s) |
1658 (while (string-match "\\([^\\\\]\\)\\(&\\)" s) | 1941 (while (string-match "\\([^\\\\]\\)\\(&\\)" s) |
1659 (setq s (replace-match (concat (match-string 1 s) "\\" (match-string 2 s)) | 1942 (setq s (replace-match (concat (match-string 1 s) "\\" (match-string 2 s)) |
1660 t t s))) | 1943 t t s))) |
1703 (goto-char (point-min)) | 1986 (goto-char (point-min)) |
1704 (while (re-search-forward re nil t) | 1987 (while (re-search-forward re nil t) |
1705 (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0)) | 1988 (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0)) |
1706 (add-text-properties beg end '(org-protected t org-latex-math t)))))) | 1989 (add-text-properties beg end '(org-protected t org-latex-math t)))))) |
1707 | 1990 |
1708 ;; Convert LaTeX to \LaTeX{} | 1991 ;; Convert LaTeX to \LaTeX{} and TeX to \TeX{} |
1709 (goto-char (point-min)) | 1992 (goto-char (point-min)) |
1710 (let ((case-fold-search nil)) | 1993 (let ((case-fold-search nil)) |
1711 (while (re-search-forward "\\([^+_]\\)LaTeX" nil t) | 1994 (while (re-search-forward "\\<\\(\\(La\\)?TeX\\)\\>" nil t) |
1712 (org-if-unprotected | 1995 (unless (eq (char-before (match-beginning 1)) ?\\) |
1713 (replace-match (org-export-latex-protect-string | 1996 (org-if-unprotected-1 |
1714 (concat (match-string 1) "\\LaTeX{}")) t t)))) | 1997 (replace-match (org-export-latex-protect-string |
1998 (concat "\\" (match-string 1) | |
1999 "{}")) t t))))) | |
1715 | 2000 |
1716 ;; Convert blockquotes | 2001 ;; Convert blockquotes |
1717 (goto-char (point-min)) | 2002 (goto-char (point-min)) |
1718 (while (search-forward "ORG-BLOCKQUOTE-START" nil t) | 2003 (while (search-forward "ORG-BLOCKQUOTE-START" nil t) |
1719 (org-replace-match-keep-properties "\\begin{quote}" t t)) | 2004 (org-replace-match-keep-properties "\\begin{quote}" t t)) |
1757 (while (re-search-forward "^----+.$" nil t) | 2042 (while (re-search-forward "^----+.$" nil t) |
1758 (org-if-unprotected | 2043 (org-if-unprotected |
1759 (replace-match (org-export-latex-protect-string "\\hrule") t t))) | 2044 (replace-match (org-export-latex-protect-string "\\hrule") t t))) |
1760 | 2045 |
1761 ;; Protect LaTeX commands like \command[...]{...} or \command{...} | 2046 ;; Protect LaTeX commands like \command[...]{...} or \command{...} |
1762 (let ((re (concat "\\\\[a-zA-Z]+\\(?:" | 2047 (goto-char (point-min)) |
1763 "\\[.*\\]" | 2048 (let ((re (concat |
1764 "\\)?" | 2049 "\\\\\\([a-zA-Z]+\\)" |
1765 (org-create-multibrace-regexp "{" "}" 3)))) | 2050 "\\(?:<[^<>\n]*>\\)*" |
2051 "\\(?:\\[[^][\n]*?\\]\\)*" | |
2052 "\\(?:<[^<>\n]*>\\)*" | |
2053 "\\(" (org-create-multibrace-regexp "{" "}" 3) "\\)\\{1,3\\}"))) | |
1766 (while (re-search-forward re nil t) | 2054 (while (re-search-forward re nil t) |
1767 (unless (save-excursion (goto-char (match-beginning 0)) | 2055 (unless (or |
1768 (equal (char-after (point-at-bol)) ?#)) | 2056 ;; check for comment line |
2057 (save-excursion (goto-char (match-beginning 0)) | |
2058 (equal (char-after (point-at-bol)) ?#)) | |
2059 ;; Check if this is a defined entity, so that is may need conversion | |
2060 (org-entity-get (match-string 1)) | |
2061 ) | |
1769 (add-text-properties (match-beginning 0) (match-end 0) | 2062 (add-text-properties (match-beginning 0) (match-end 0) |
1770 '(org-protected t))))) | 2063 '(org-protected t))))) |
1771 | 2064 |
1772 ;; Protect LaTeX entities | 2065 ;; Protect LaTeX entities |
1773 (goto-char (point-min)) | 2066 (goto-char (point-min)) |
1784 (while (re-search-forward | 2077 (while (re-search-forward |
1785 (concat "<<<?" org-export-latex-all-targets-re | 2078 (concat "<<<?" org-export-latex-all-targets-re |
1786 ">>>?\\((INVISIBLE)\\)?") nil t) | 2079 ">>>?\\((INVISIBLE)\\)?") nil t) |
1787 (org-if-unprotected-at (+ (match-beginning 0) 2) | 2080 (org-if-unprotected-at (+ (match-beginning 0) 2) |
1788 (replace-match | 2081 (replace-match |
1789 (org-export-latex-protect-string | 2082 (concat |
1790 (format "\\label{%s}%s" (save-match-data (org-solidify-link-text | 2083 (org-export-latex-protect-string |
1791 (match-string 1))) | 2084 (format "\\label{%s}" (save-match-data (org-solidify-link-text |
1792 (if (match-string 2) "" (match-string 1)))) t t))) | 2085 (match-string 1))))) |
2086 (if (match-string 2) "" (match-string 1))) | |
2087 t t))) | |
1793 | 2088 |
1794 ;; Delete @<...> constructs | 2089 ;; Delete @<...> constructs |
1795 ;; Thanks to Daniel Clemente for this regexp | 2090 ;; Thanks to Daniel Clemente for this regexp |
1796 (goto-char (point-min)) | 2091 (goto-char (point-min)) |
1797 (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t) | 2092 (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t) |
1830 (setq footnote-rpl (format "\\footnote{%s}" footnote)) | 2125 (setq footnote-rpl (format "\\footnote{%s}" footnote)) |
1831 (add-text-properties 0 10 '(org-protected t) footnote-rpl) | 2126 (add-text-properties 0 10 '(org-protected t) footnote-rpl) |
1832 (add-text-properties (1- (length footnote-rpl)) | 2127 (add-text-properties (1- (length footnote-rpl)) |
1833 (length footnote-rpl) | 2128 (length footnote-rpl) |
1834 '(org-protected t) footnote-rpl) | 2129 '(org-protected t) footnote-rpl) |
2130 (if (org-on-heading-p) | |
2131 (setq footnote-rpl | |
2132 (concat (org-export-latex-protect-string "\\protect") | |
2133 footnote-rpl))) | |
1835 (insert footnote-rpl))) | 2134 (insert footnote-rpl))) |
1836 ))))) | 2135 ))))) |
1837 | 2136 |
1838 ;; Remove footnote section tag for LaTeX | 2137 ;; Remove footnote section tag for LaTeX |
1839 (goto-char (point-min)) | 2138 (goto-char (point-min)) |
1840 (while (re-search-forward | 2139 (while (re-search-forward |
1841 (concat "^" footnote-section-tag-regexp) nil t) | 2140 (concat "^" footnote-section-tag-regexp) nil t) |
1842 (org-if-unprotected | 2141 (org-if-unprotected |
1843 (replace-match ""))))) | 2142 (replace-match ""))))) |
2143 | |
2144 (defun org-export-latex-fix-inputenc () | |
2145 "Set the codingsystem in inputenc to what the buffer is." | |
2146 (let* ((cs buffer-file-coding-system) | |
2147 (opt (or (ignore-errors (latexenc-coding-system-to-inputenc cs)) | |
2148 "utf8"))) | |
2149 (when opt | |
2150 ;; Translate if that is requested | |
2151 (setq opt (or (cdr (assoc opt org-export-latex-inputenc-alist)) opt)) | |
2152 ;; find the \usepackage statement and replace the option | |
2153 (goto-char (point-min)) | |
2154 (while (re-search-forward "\\\\usepackage\\[\\(AUTO\\)\\]{inputenc}" | |
2155 nil t) | |
2156 (goto-char (match-beginning 1)) | |
2157 (delete-region (match-beginning 1) (match-end 1)) | |
2158 (insert opt)) | |
2159 (and buffer-file-name | |
2160 (save-buffer))))) | |
1844 | 2161 |
1845 ;;; List handling: | 2162 ;;; List handling: |
1846 | 2163 |
1847 (defun org-export-latex-lists () | 2164 (defun org-export-latex-lists () |
1848 "Convert plain text lists in current buffer into LaTeX lists." | 2165 "Convert plain text lists in current buffer into LaTeX lists." |