5

When I insert an image into the slide it gets cropped to fit into the slide. How do make an image to scale to fit in without cropping or padding?

To include an image I use:

#+LaTeX:\includegraphics{curves.jpg}

org file header:

#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
#+BEAMER_FRAME_LEVEL: 2
#+OPTIONS: toc:nil

and config file contains the following:

; allow for export=>beamer by placing

;; #+LaTeX_CLASS: beamer in org files
(unless (boundp 'org-export-latex-classes)
  (setq org-export-latex-classes nil))
(add-to-list 'org-export-latex-classes
  ;; beamer class, for presentations
  '("beamer"
     "\\documentclass[11pt]{beamer}\n
      \\mode<{{{beamermode}}}>\n
      \\usetheme{{{{beamertheme}}}}\n
      \\usecolortheme{{{{beamercolortheme}}}}\n
      \\beamertemplateballitem\n
      \\setbeameroption{show notes}
      \\usepackage[utf8]{inputenc}\n
      \\usepackage[T1]{fontenc}\n
      \\usepackage{hyperref}\n
      \\usepackage{color}
      \\usepackage{listings}
      \\lstset{numbers=none,language=[ISO]C++,tabsize=4,
  frame=single,
  basicstyle=\\small,
  showspaces=false,showstringspaces=false,
  showtabs=false,
  keywordstyle=\\color{blue}\\bfseries,
  commentstyle=\\color{red},
  }\n
      \\usepackage{verbatim}\n
      \\institute{{{{beamerinstitute}}}}\n          
       \\subject{{{{beamersubject}}}}\n"

     ("\\section{%s}" . "\\section*{%s}")

     ("\\begin{frame}[fragile]\\frametitle{%s}"
       "\\end{frame}"
       "\\begin{frame}[fragile]\\frametitle{%s}"
       "\\end{frame}")))

  ;; letter class, for formal letters

  (add-to-list 'org-export-latex-classes

  '("letter"
     "\\documentclass[11pt]{letter}\n
      \\usepackage[utf8]{inputenc}\n
      \\usepackage[T1]{fontenc}\n
      \\usepackage{color}"

     ("\\section{%s}" . "\\section*{%s}")
     ("\\subsection{%s}" . "\\subsection*{%s}")
     ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
     ("\\paragraph{%s}" . "\\paragraph*{%s}")
     ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

5

Another option is to use

#+ATTR_LATEX: :width 1.06\textwidth
[[file:curves.jpg]]

This is described here: https://orgmode.org/manual/Images-in-LaTeX-export.html

For specifying image ‘:width’, ‘:height’, and other ‘:options’, use this syntax:

#+ATTR_LATEX: :width 5cm :options angle=90
[[./img/sed-hr4049.pdf]]
3
  • Can you add a relevant quote from the documentation? Links might break over time, and it's expected to add a relevant quote to your answer.
    – user12563
    Sep 3 '19 at 15:31
  • I think there is a typo in the first snippet. 10.6 times the text width is almost guaranteed to make the image not fit into the slide. Is it maybe 1.06?
    – logc
    Jul 4 '20 at 6:13
  • Have you seen the size of my slides? :-) Seriously, though, you are right of course. In fact, the factor is in general probably going to be less that one.
    – loris
    Jul 6 '20 at 8:08
3

after countless hours of research here is the solution. includegraphics accepts width parameter and by using textwidth variable we could set the correct size.

#+LaTeX:\includegraphics[width = 1.06\textwidth]{curves.jpg}
2
  • Is it possible to set it for all images in a file?
    – Rotkiv
    Jan 18 at 15:36
  • 1
    @Rotkiv checkout the answer below, it might be a better option in your situation, just explicitly state attribute for each image you include. You could prob do an expansion on export if line contains .jpg insert the attribute above
    – A_P
    Jan 18 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.