aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2013-05-07 16:01:11 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2013-05-07 16:01:11 -0700
commit2c876edb6026e059f9cd0112ecd30e474866808e (patch)
tree444c5266e5b56e225aea480cd8330a18f85a7963
parentfd59e11e15d0dc5a7187bba79f1a5adf294a1c35 (diff)
downloadpandoc-2c876edb6026e059f9cd0112ecd30e474866808e.tar.gz
default.latex: Redefine includegraphics to allow custom options.
Thanks to Bernhard Weichel. Now, literal \includegraphics commands with square-bracketed options will work properly. When no options are given, a default option limits images to the text width.
-rw-r--r--default.latex10
1 files changed, 7 insertions, 3 deletions
diff --git a/default.latex b/default.latex
index 1f5181323..c91a03861 100644
--- a/default.latex
+++ b/default.latex
@@ -65,15 +65,19 @@ $if(tables)$
$endif$
$if(graphics)$
\usepackage{graphicx}
-% We will generate all images so they have a width \maxwidth. This means
-% that they will get their normal width if they fit onto the page, but
+% Redefine \includegraphics so that, unless explicit options are
+% given, the image width will not exceed the width of the page.
+% Images get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
-\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
+{%
+ \catcode`\@=11\relax%
+ \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\maxwidth]}}%
+}%
$endif$
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex