pandoc, markdown이 포함된 라텍스 템플릿의 PDF 이미지 프레임 테두리

pandoc, markdown이 포함된 라텍스 템플릿의 PDF 이미지 프레임 테두리

나는 다음과 비슷한 tex 템플릿을 사용하고 있습니다. https://github.com/davecap/markdown-latex-boilerplate/blob/master/template.tex

표준 마크다운 코드에서 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}} 
---

![](Screenshot_20200131_230154.png){ 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}}'

관련 정보