
Я использую шаблон tex, похожий на https://github.com/davecap/markdown-latex-boilerplate/blob/master/template.tex
Как мне получить рамку вокруг изображений, которые передаются из стандартного кода markdown в шаблон tex?
Очевидно, что этот код обрабатывает размеры изображений, но как мне добавить графические кадры?
$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}
решение1
Не редактируя шаблон, вы можете использоватьБлок метаданных YAMLпередать параметры, которые переопределят \includegraphics
так, чтобы всегда добавлялся кадр,аналогично тому, что сделано здесь.
Возьмем, к примеру, эту картинку и назовем ее Screenshot_20200131_230154.png
:
Затем следующий файл разметки test.md
:
---
header-includes: |
\usepackage[export]{adjustbox}
\let\includegraphicsbak\includegraphics
\renewcommand*{\includegraphics}[2][]{\includegraphicsbak[frame,#1]{#2}}
---
{ width=150px height=150px }
при компиляции с помощью даст pandoc test.md -o test.pdf
:
решение2
Я не нашел, как заставить работать шаблон yaml, поэтому я использовал опции @Clément в качестве параметров CLI:
pandoc --pdf-engine xelatex \
[…]
-V header-includes:'\usepackage[export]{adjustbox} \let\includegraphicsbak\includegraphics \renewcommand*{\includegraphics}[2][]{\includegraphicsbak[frame,#1]{#2}}'