虛線不列印 (TikZ)

虛線不列印 (TikZ)

我有幾個包含虛線的圖形。在 PDF 中,一切看起來都一模一樣。然而,當我列印時,虛線完全消失。我該怎麼做才能防止這種情況發生?

\begin{tikzpicture}
\node (a) at (0,1) [vertex] {};
\node (b) at (0.7,1.7) [vertex] {};
\node (c) at (1.7,1.7) [vertex] {};
\node (d) at (2.4,1) [vertex] {};
\node (e) at (1.7,0.3) [vertex] {};
\node (f) at (0.7,0.3) [vertex] {};
\draw (a) -- (b);
\draw (b) -- (c);
\draw (c) -- (d);
\draw (d) -- (e);
\draw (e) -- (f);
\draw [dashed] (f) -- (a);
\end{tikzpicture}

答案1

我的工作涉及透過電子郵件將大量 PDF 發送給人們進行列印,因此「更新印表機驅動程式」解決方案並不能真正幫助我。

但我發現,雖然點或虛線拒絕列印點線或虛線正弦波即使幅度為零,也顯示良好。所以我將以下內容放在文件的頂部:

\usetikzlibrary{snakes}
\tikzstyle{printersafe}=[snake=snake,segment amplitude=0 pt]

然後將 [printersafe] 作為樣式添加到程式碼中的每個虛線,例如:

\draw [densely dotted,printersafe] (0,-6) -- (10,-6);

即使由經歷過原始問題的助教打印,這些線條也顯示得很好。

答案2

所以,我最近遇到了這個問題並找到了@Jonah的解決方案。問題是,它實際上並不適合 tikz 現在的行為方式,所以我做了以下更改,這應該會使此程式碼更加最新:

\usetikzlibrary{decorations.pathmorphing}
\tikzstyle{printersafe}=[decoration={snake,amplitude=0pt}]

這樣您也可以在 tikz-cd 環境中使用 Printersafe。希望這可以幫助!

答案3

使用新印表機解決了這個問題,所以顯然正如保羅所建議的那樣,這是一個驅動程式問題。

答案4

另一個解決方案:繪製自己的虛線

看起來 Tikz 並不總是按照我們期望的那樣做。特別是與諸如圓形箭頭之類的自訂功能相結合edge[transform canvas={xshift=4}],可以在這個帖子。在這些情況下,印表機有時不會列印正常的虛線。這就是為什麼我們需要使用解決方法。

另一個答案是印表機安全不適合我。另外,我想將 pdf 發送給其他人,這樣我就無法更新他們的印表機。我需要一個始終有效的解決方案。

我找到了一種解決方法,使用foreach帶有法線的循環來模擬虛線:

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{figure}[h!]
\begin{tikzpicture}[every path/.style={>=latex}]

% Normal dashed line
\draw[->,thick,black,dashed] (0,1) -- (4,1) node[anchor=west] {Normal dashed line};

% Specify dashed line starting coordinate and length
\def\x{0}; \def\y{0}; \def\length{4} \def\N{19}; 
% Draw dashed line using normal lines
\pgfmathsetmacro{\step}{(0.5+1/(4*\N))*\length/\N}; \pgfmathparse{\N-1};
\foreach \i in {0,...,\pgfmathresult} {\draw[thick,black] (\x+2*\i*\step,\y) -- (\x+2*\i*\step+\step,\y);}; 
\draw[->,thick,black] (\x+\length,\y) -- (\x+\length+0.01,\y) node[anchor=west] {Custom dashed line};

\end{tikzpicture}
\end{figure}
\end{document}

這只是透過在彼此之後繪製多條線來模仿正常的虛線。參數\x用於起始 x 座標、\y線的 y 水平、\length線座標長度、\N條紋數量。

提供的範例僅從左到右繪製水平線,但可以輕鬆調整程式碼以繪製其他虛線(例如垂直線、從右到左等)

如果您的印表機,此解決方案仍然允許您列印虛線列印正常的線條,但虛線不顯示(由於某種原因)。

輸出為pdf:

pdf箭頭

相關內容