使用imagemagick将LaTeX pdf文件转换为png文件会在突出显示的文本周围添加彩色线条

时间:2018-04-18 10:27:34

标签: imagemagick latex imagemagick-convert anki

我使用LaTeX创建Anki抽认卡,使用imagemagick从.pdf转换为.png,以便它们可以与Anki一起使用。

我想在蓝色或灰色背景的闪存卡中突出显示一些内联代码片段,我尝试在两种方式的LaTeX代码中实现,如下例所示:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{microtype}

\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc} 
\usepackage{lmodern}

\usepackage[parfill]{parskip} % turns off indentation at beginning of new paragraphs and adds a little bit of (stretchable) space in between paragraphs.
\usepackage{mathtools}
\usepackage{textcomp}     % access \textquotesingle

% Grey background and typwriter font for inline code
% https://tex.stackexchange.com/questions/140166/making-inline-code-printing-pretty
\usepackage{tikz}
\newcommand\code[2][]{\!\!
    \tikz[baseline=(s.base)]{
        \node(s)[
            fill=blue!10,           % background color
            %draw=blue!50,          % border of box
            inner xsep =3pt,    % horizontal space between text and border
            inner ysep =0pt,    % vertical space between text and border
            text height=2ex,    % height of box
            text depth =1ex,    % depth of box
            #1                  % other options
        ]{\texttt{#2}};
    }\!\!
}

% Grey background and typwriter font for inline code version 2
\definecolor{codegray}{gray}{0.9}
\newcommand{\codex}[1]{\colorbox{codegray}{\texttt{#1}}}


\begin{document}
Assuming you are writing in English, use \code{\`{}\`{}quoted\textquotesingle\textquotesingle} to get the result ``quoted'' (or \code{\`{}quoted\textquotesingle} for `quoted'). Note that in some languages, babel uses the \code{"} character for various purposes not related to quotation marks, so it really is best to avoid it.

Assuming you are writing in English, use \codex{\`{}\`{}quoted\textquotesingle\textquotesingle} to get the result ``quoted'' (or \codex{\`{}quoted\textquotesingle} for `quoted'). Note that in some languages, babel uses the \codex{"} character for various purposes not related to quotation marks, so it really is best to avoid it.
\end{document}

这会产生this .pdf文件,由我的pdf-viewer查看并使用Windows Snipping Tool裁剪。但是,在使用imagemagick进行转换和裁剪之后,会出现一些新添加的黄色和/或灰色线条,如here所示。

使用的imagemagick命令是:

magick -density 288 tmp.pdf -trim tmp.png

所以我想知道,为什么会添加不同颜色的线条,以及如何防止这种情况发生?

0 个答案:

没有答案