我在文件中使用了精美的 TikZ 陰影pdflatex
,效果很好。但是,如果我使用 Ghostscript(或其前端)處理 PDF 文檔ps2pdf
,陰影就會被破壞。由於圖像較多,處理的目的是減小文件的大小,我認為這是一個不相關的問題。
以下是詳細資訊。氣象局:
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit}
\usetikzlibrary{through}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{shadows}
\usetikzlibrary{shadings}
%% even fancier shadows
\usetikzlibrary{shadows.blur}
%% fade
\usetikzlibrary{fadings}
\begin{document}
\begin{tikzpicture}[align=center,node distance = 1.2em and 1.2em,
rounded corners=10, blur shadow={shadow blur steps=50}]
\tikzstyle{block} = [rectangle, fill=blue!10, draw, text width=6em,
text centered, minimum height=2.1\baselineskip,
blur shadow={shadow blur steps=50}
]
\node (t) [block] {Test};
\end{tikzpicture}
\end{document}
之後的原始文件latexmk -pdf mwe
:
現在,我打電話gs
:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.7 -dPDFSETTINGS=/printer -dColorImageDownsampleType=/Bicubic -dColorImageResolution=72 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=72 -dMonoImageResolution=150 -dOptimize=true -q -o small-gs.pdf mwe.pdf
結果是:
我也可以呼叫ps2pdf
: ps2pdf mwe.pdf small-2pdf.pdf
,結果是一樣的。 (難怪,它是一個前端gs
。)
版本:
$ pdflatex --version
pdfTeX 3.14159265-2.6-1.40.21 (TeX Live 2020)
kpathsea version 6.3.2
Copyright 2020 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.02
$ gs --version
9.52
在 MacOS 10.15.6 和 GitLab 上的建置系統(texlive-latest
Ubuntu 映像)上進行了驗證。我在 Preview.app 中查看 PDF。
我究竟做錯了什麼? (顯然,除了使用預覽之外。)
如何保留 PDF 文件更廣泛的兼容性?
答案1
最近添加了對dvips
+的淡入淡出(非均勻透明度)的支持,並且僅在其中可用ps2pdf
pgf
GitHub 儲存庫。如需測試,請下載https://github.com/pgf-tikz/pgf/archive/master.zip並複製tex
將其中的資料夾複製到工作目錄中。此外,還需要 Ghostscript-9.52,ps2pdf
必須使用選項運行-dALLOWPSTRANSPARENCY
。