From: "Francesco Pizzolante" <fpz-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org>
To: mailing-list-org-mode <emacs-orgmode-mXXj517/zsQ@public.gmane.org>
Subject: Centering graphics in LaTeX export
Date: Thu, 15 May 2014 17:25:02 +0200 [thread overview]
Message-ID: <87vbt79i9d.fsf@somewhere.org> (raw)
Hi,
Here's a small patch that enables centering graphics in LaTeX exports
(as it already exists for tables).
Currently, the only way to center images is by adding a caption (which
is not always needed) or by adding #+begin_center / #+end_center around
images (but it must be done for every image as we cannot define
a default behavior for centering images).
Thanks to this patch:
- an image can be centered by adding the ':center t' attribute in
a '#+ATTR_LATEX' directive (as for tables);
- default centering of images can be achieved by setting the
'org-latex-images-centered' variable to t.
Could you please apply this patch?
Thanks.
Best regards,
Francesco Pizzolante
--- C:\Users\fpz\Documents\home\.emacs.d\elpa\org-plus-contrib-20140512\ox-latex.el 2014-05-15 17:09:08.000000000 +0200
+++ C:\Users\fpz\Documents\home\.emacs.d\elpa\org-plus-contrib-20140505 - Copy\ox-latex.el 2014-05-15 17:11:25.000000000 +0200
@@ -401,12 +401,17 @@
"Default option for images."
:group 'org-export-latex
:version "24.4"
:package-version '(Org . "8.0")
:type 'string)
+(defcustom org-latex-images-centered t
+ "When non-nil, images are exported in a center environment."
+ :group 'org-export-latex
+ :type 'boolean)
+
(defcustom org-latex-image-default-width ".9\\linewidth"
"Default width for images.
This value will not be used if a height is provided."
:group 'org-export-latex
:version "24.4"
:package-version '(Org . "8.0")
@@ -1710,12 +1715,15 @@
((eq float 'figure)
(format "[%s]" org-latex-default-figure-position))
(t ""))))
(comment-include (if (plist-get attr :comment-include) "%" ""))
;; It is possible to specify width and height in the
;; ATTR_LATEX line, and also via default variables.
+ (centerp (if (plist-member attr :center)
+ (plist-get attr :center)
+ org-latex-images-centered))
(width (cond ((plist-get attr :width))
((plist-get attr :height) "")
((eq float 'wrap) "0.48\\textwidth")
(t org-latex-image-default-width)))
(height (cond ((plist-get attr :height))
((or (plist-get attr :width)
@@ -1749,18 +1757,21 @@
;; - include the image with \includegraphics.
(when (org-string-nw-p width)
(setq options (concat options ",width=" width)))
(when (org-string-nw-p height)
(setq options (concat options ",height=" height)))
(setq image-code
- (format "\\includegraphics%s{%s}"
+ (format "%s\\includegraphics%s{%s}%s"
+ (if centerp "{\\centering\n" "")
(cond ((not (org-string-nw-p options)) "")
((= (aref options 0) ?,)
(format "[%s]"(substring options 1)))
(t (format "[%s]" options)))
- path))
+ path
+ (if centerp "\\par}\n" "")
+ ))
(when (equal filetype "svg")
(setq image-code (replace-regexp-in-string "^\\\\includegraphics"
"\\includesvg"
image-code
nil t))
(setq image-code (replace-regexp-in-string "\\.svg}"
next reply other threads:[~2014-05-15 15:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-15 15:25 Francesco Pizzolante [this message]
2014-05-15 15:28 ` Centering graphics in LaTeX export John Hendy
2014-05-16 8:51 ` Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vbt79i9d.fsf@somewhere.org \
--to=fpz-djc/ipccudyqhejpep6iedvlejwurmry@public.gmane.org \
--cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).