
下面的程式碼很簡單,但對於顯示問題很重要。當我啟動showgrid
withtrue
或top
選項時,我的圖形物件會向右移動,如以下動畫所示。
\documentclass[pstricks,border=12pt]{standalone}
\def\Atom{\psframe(1,2)(2,3)}
\begin{document}
% NO problem WITHOUT showgrid or with showgrid=bottom
\begin{pspicture}[showgrid=bottom](2,4)
\begin{psclip}{\Atom}
\psframe*(2,4)
\end{psclip}
\end{pspicture}
% get shifted to the right with showgrid=true or showgrid=top
\begin{pspicture}[showgrid=true](2,4)
\begin{psclip}{\Atom}
\psframe*(2,4)
\end{psclip}
\end{pspicture}
\end{document}
警告:
showgrid=true
等於showgrid=top
而不是showgrid=bottom
。- 第 4 頁的聲明
pst-news12.pdf
可能輸入錯誤。
是什麼造成了這種位移?
答案1
使用這個版本:http://texnik.dante.de/tex/generic/pstricks/pstricks.tex 它有一個錯誤修復。
答案2
請注意我上面的評論:
showgrid=top
會導致什麼?它將包括\psgrid
在結尾- 環境的pspicture
。這可能是問題所在,因為透過在最後繪製網格,一切都會改變...
該解決方案將產生一個正確的版本(首先繪製網格以將所有內容設定正確,並在最後繪製另一個網格以使其位於頂部):
\begin{pspicture}[showgrid=bottom](2,4)
\begin{psclip}{\Atom}
\psframe*(2,4)
\end{psclip}
\psgrid[style=gridstyle]
\end{pspicture}
末尾有一個空格
\ifx#1t
在下面的程式碼片段中。
% ----------- hv 20120219 -------------------
\newpsstyle{gridstyle}{subgriddiv=0,gridcolor=lightgray,griddots=10,gridlabels=8pt}
%\define@boolkey[psset]{pstricks}[]{showgrid}[true]{}
\newif\ifshowgrid
\define@key[psset]{pstricks}{showgrid}[b]{\pst@@showgrid#1\@nil}
\def\pst@@showgrid#1#2\@nil{%
\ifx#1b\showgridtrue\def\showgridp@s{0}\else% bottom
\ifx#1f\showgridfalse\else
\ifx#1t
\ifx#2r\showgridtrue\def\showgridp@s{0}\else% true->bottom
\showgridtrue\def\showgridp@s{1}\fi% top
\fi\fi\fi%
}