Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

always include long table and graphics, do not limit includegraphics #26

Closed
wants to merge 4 commits into from

2 participants

@bwl21

always include longtable
always include graphics

improved redefinition of include graphics such that it still can be used with options. This is to allow specific includegraphics embedded in markdown.

If one provides a latex stuff by --include-before-body or --include-after-body he should have the ability to provide tables and graphics there.

redefinition of includegraphics should not diminish the features of includegraphics if used in latex file directly or embedded in markdown.

@bwl21 bwl21 always include long table
always include graphics

improved redefinition of include graphics such that it still can be used with options. This is to allow specific includegraphics embedded in markdown.
e29853d
@jgm
Owner
jgm commented

Thanks, I've implemented your idea for includegraphics (crediting you). I still want to include longtable and graphicx conditionally, however. You can remove the conditionals in your own template if you like.

@jgm
Owner
jgm commented

PS. I tried the same definition for includegraphics in the beamer template, and it didn't work properly (no auto-scaling of an overlarge image). I'm not sure why.

@bwl21

What is the benefit of the condition for longtable and graphicx? One does not notices these packages unless they are used.

I will try to find out, why it does not work in the beamer template.

@jgm
Owner
jgm commented
@bwl21

That sounds reasonable. As I wrapped pandoc in an extra environment (https://github.com/bwl21/wortsammler) It would not be a problem to pass a variable to include this.

Is it possible to set the variables table and graphics in the commandline in order to include the packages?

I would really be able to use default.latex as is because it really contains pandoc specifics. For the particular application I prefer to have an extra package which is activated by \usepackage{wortsammler}. Then the levels of pandoc and wortsammer are fairly separated.

@jgm
Owner
jgm commented
bwl21 added some commits
@bwl21 bwl21 Comment by Dr. Reinhard Jahraus
"beamer" changes within  \begin{document}   the behavior of many standard commands, amongst others also \includegraphics. This removed the option to scale the included image. In addition to this, "beamer" ignores everything in \begin{document} which is not \begin{frame}. This os not that easy to find. However the solution looks more easy than one can expect based on the problem analysis. The solution is to wrap the redefinition into \AtBeginDocument. This should work in the other latex classes as well.

Die Klasse "beamer"  \begin{document} verbiegt innerhalb von \begin{document} viele Standardbefehle. U.a. auch \includegraphics. Dadurch ging die Skalierungsoption verloren. Zusätzliche Probleme bei der Analyse entstanden dadurch, dass in der beamer-Klasse nach \begin{document} alles was nicht \begin{frame} heißt, ignoriert wird. Darauf muss man erstmal kommen. Nun, die Lösung sieht einfacher aus, als aufgrund der Komplexität zu erwarten wäre. Ich habe es nicht getestet, aber ich erwarte, dass diese Zeilen so auch in anderen Klassen funktionieren.
2ed5606
@bwl21 bwl21 Comment by Dr. Reinhard Jahraus
"beamer" changes within  \begin{document}   the behavior of many standard commands, amongst others also \includegraphics. This removed the option to scale the included image. In addition to this, "beamer" ignores everything in \begin{document} which is not \begin{frame}. This os not that easy to find. However the solution looks more easy than one can expect based on the problem analysis. The solution is to wrap the redefinition into \AtBeginDocument. This should work in the other latex classes as well.

For sake of consistency, I ported the solution also to default.latex. As Reinhard pointed out, it really works.
d8e5e56
@jgm jgm closed this pull request from a commit
@yihui yihui Use \setkeys{Gin}{} to set appropriate defaults for \includegraphics,…
… instead of entirely redefining this command.

Note we also consider the height of images; if an image is too high, 0.8\textheight will be used for beamer slides, and \textheight is used for articles (see http://tex.stackexchange.com/q/11954/9128).

If the user has explicitly provided the width/height options in \includegraphics[], our defaults will be overwritten, and this approach is better than the check `\@ifnextchar[` after \includegraphics because the latter approach simply gives up everything once it sees [, whereas \setkeys{Gin} can keep the good defaults unless they are explicitly overwritten in [].

closes #30, closes #28, and closes #26
a3cce8d
@jgm jgm closed this in a3cce8d
@jrbing jrbing referenced this pull request from a commit in jrbing/pandoc-templates
@yihui yihui Use \setkeys{Gin}{} to set appropriate defaults for \includegraphics,…
… instead of entirely redefining this command.

Note we also consider the height of images; if an image is too high, 0.8\textheight will be used for beamer slides, and \textheight is used for articles (see http://tex.stackexchange.com/q/11954/9128).

If the user has explicitly provided the width/height options in \includegraphics[], our defaults will be overwritten, and this approach is better than the check `\@ifnextchar[` after \includegraphics because the latter approach simply gives up everything once it sees [, whereas \setkeys{Gin} can keep the good defaults unless they are explicitly overwritten in [].

closes #30, closes #28, and closes #26
05ce16e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 4, 2013
  1. @bwl21

    always include long table

    bwl21 authored
    always include graphics
    
    improved redefinition of include graphics such that it still can be used with options. This is to allow specific includegraphics embedded in markdown.
Commits on May 8, 2013
  1. @bwl21

    Merge branch 'master' into HEAD

    bwl21 authored
Commits on May 10, 2013
  1. @bwl21

    Comment by Dr. Reinhard Jahraus

    bwl21 authored
    "beamer" changes within  \begin{document}   the behavior of many standard commands, amongst others also \includegraphics. This removed the option to scale the included image. In addition to this, "beamer" ignores everything in \begin{document} which is not \begin{frame}. This os not that easy to find. However the solution looks more easy than one can expect based on the problem analysis. The solution is to wrap the redefinition into \AtBeginDocument. This should work in the other latex classes as well.
    
    Die Klasse "beamer"  \begin{document} verbiegt innerhalb von \begin{document} viele Standardbefehle. U.a. auch \includegraphics. Dadurch ging die Skalierungsoption verloren. Zusätzliche Probleme bei der Analyse entstanden dadurch, dass in der beamer-Klasse nach \begin{document} alles was nicht \begin{frame} heißt, ignoriert wird. Darauf muss man erstmal kommen. Nun, die Lösung sieht einfacher aus, als aufgrund der Komplexität zu erwarten wäre. Ich habe es nicht getestet, aber ich erwarte, dass diese Zeilen so auch in anderen Klassen funktionieren.
  2. @bwl21

    Comment by Dr. Reinhard Jahraus

    bwl21 authored
    "beamer" changes within  \begin{document}   the behavior of many standard commands, amongst others also \includegraphics. This removed the option to scale the included image. In addition to this, "beamer" ignores everything in \begin{document} which is not \begin{frame}. This os not that easy to find. However the solution looks more easy than one can expect based on the problem analysis. The solution is to wrap the redefinition into \AtBeginDocument. This should work in the other latex classes as well.
    
    For sake of consistency, I ported the solution also to default.latex. As Reinhard pointed out, it really works.
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 13 deletions.
  1. +11 −5 default.beamer
  2. +11 −8 default.latex
View
16 default.beamer
@@ -59,15 +59,21 @@ $if(graphics)$
% are scaled down if they would overflow the margins.
\makeatletter
\def\ScaleIfNeeded{%
- \ifdim\Gin@nat@width>\linewidth
- \linewidth
+ \ifdim\Gin@nat@width>\linewidth%
+ \linewidth\relax%
\else
- \Gin@nat@width
+ \Gin@nat@width\relax%
\fi
}
+\AtBeginDocument%
+ {%
+ \let\Oldincludegraphics\includegraphics%
+ \gdef\includegraphics%
+ {%
+ \@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}%
+ }%
+ }%
\makeatother
-\let\Oldincludegraphics\includegraphics
-\renewcommand{\includegraphics}[2][]{\Oldincludegraphics[width=\ScaleIfNeeded]{#2}}
$endif$
% Comment these out if you don't want a slide with just the
View
19 default.latex
@@ -71,18 +71,21 @@ $if(graphics)$
% are scaled down if they would overflow the margins.
\makeatletter
\def\ScaleIfNeeded{%
- \ifdim\Gin@nat@width>\linewidth
- \linewidth
+ \ifdim\Gin@nat@width>\linewidth%
+ \linewidth\relax%
\else
- \Gin@nat@width
+ \Gin@nat@width\relax%
\fi
}
+\AtBeginDocument%
+ {%
+ \let\Oldincludegraphics\includegraphics%
+ \gdef\includegraphics%
+ {%
+ \@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}%
+ }%
+ }%
\makeatother
-\let\Oldincludegraphics\includegraphics
-{%
- \catcode`\@=11\relax%
- \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
-}%
$endif$
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex
Something went wrong with that request. Please try again.