
Estoy usando una plantilla de texto similar a https://github.com/davecap/markdown-latex-boilerplate/blob/master/template.tex
¿Cómo puedo obtener un marco alrededor de las imágenes que se pasan del código de rebajas estándar a la plantilla de texto?
Obviamente este código maneja los tamaños de las imágenes, pero ¿cómo puedo agregar los marcos de los gráficos?
$if(graphics)$
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
$endif$
...
\begin{document}
$body$
\end{document}
Respuesta1
Sin editar la plantilla, puede utilizar elbloque de metadatos YAMLpara pasar opciones que se redefinirían \includegraphics
para que siempre agregara un marco,similar a lo que se hace aquí.
Tomemos, es decir, esta imagen como ejemplo y llamémosla Screenshot_20200131_230154.png
:
Luego, el siguiente archivo de rebajas test.md
:
---
header-includes: |
\usepackage[export]{adjustbox}
\let\includegraphicsbak\includegraphics
\renewcommand*{\includegraphics}[2][]{\includegraphicsbak[frame,#1]{#2}}
---
{ width=150px height=150px }
produciría, cuando se compila con pandoc test.md -o test.pdf
:
Respuesta2
No encontré cómo hacer que la plantilla yaml funcione, así que usé las opciones de @Clément como parámetros CLI:
pandoc --pdf-engine xelatex \
[…]
-V header-includes:'\usepackage[export]{adjustbox} \let\includegraphicsbak\includegraphics \renewcommand*{\includegraphics}[2][]{\includegraphicsbak[frame,#1]{#2}}'