我可以使用 \includegraphics 在每個圖像的基礎上明確設定 DPI

我可以使用 \includegraphics 在每個圖像的基礎上明確設定 DPI

我有許多圖像想要包含在我的文件中\includegraphics(或其他類似的東西)。

問題是我想根據具體情況明確覆蓋特定影像的 DPI。

也就是說,我想做這樣的事情:

\newcommand{\smalldpi}{100}
\newcommand{\largedpi}{600}

\includegraphics{foo.png}% default DPI seems to be fine for this one
\includeapicture[dpi=\smalldpi]{bar.png}
\includeapicture[dpi=\largedpi]{baz.png}

本文檔好像根本沒有提到DPI。

如何根據影像的像素尺寸和給定的 DPI 確定影像的物理尺寸?

答案1

解決方案使用pdfTeX原始和一個:

在序言中:

\newcommand{\includegraphicsdpi}[3]{
    \pdfimageresolution=#1  % Change the dpi of images
    \includegraphics[#2]{#3}
    \pdfimageresolution=72  % Change it back to the default
}

在文件中:

\includegraphicsdpi{300}{}{figures/rpi/app_main}

舊的解決方案:我曾經\includegraphics[resolution=300]{bar.png}使用 Texlive 2016 來做到這一點。我最近更新了 Texlive,它停止工作了。Package keyval Error: resolution undefined.對此提出單獨的問題,這裡

相關內容