
我使用 pstricks 和 psmatrix,以一定的頻率產生各種數字。我一直在努力解決的問題之一是如何明確控制(例如)圓形節點的半徑。為了設定半徑,我需要使用 mnode=Circle,而不是 mnode=circle。但是,我注意到,當我使用 mnode=Circle 時,節點內文本/符號的“居中”會“關閉”一些可感知的量(為了確認它“不僅僅是我”,我有 3-我班上4個不同的學生看,他們都得出了相同的結論)。
下面的 MWE 展示了這個問題——第一個圖形使用 mnode=circle (所有東西都很好地在節點內居中),第二個圖形使用 mnode=Circle (東西不居中)。也許我有點肛門,但就是這樣......
建議?修復!
謝謝...
\documentclass[10pt,letterpaper,oneside]{article}
\usepackage[dvips,top=1.2in,bottom=0.65in,left=1.0in,right=1.0in,includefoot]{geometry}
\usepackage{pst-node,pstricks-add,pst-func}
% set up float for putting figures where you want them
\usepackage{float}
\begin{document}
Using \texttt{circle}:
\begin{figure}[H]
\centering
\newpsstyle{Cempty}{fillstyle=solid,mnode=none}
\newpsstyle{Cfill}{fillstyle=solid,fillcolor=blue!7,shadow=false}
\rule[1.8cm]{0.0pt}{3.0cm}
\psscalebox{0.935}{
$
\psmatrix[colsep=1cm,rowsep=1cm,
arrowscale=1.5,mnode=circle]
[style=Cempty] ~ & [name=N1,style=Cfill] \phi_tp_t & [style=Cempty] ~\\
[name=N2,style=Cfill] \phi_. p_t & [style=Cempty] ~ & [name=N3,style=Cfill] \phi_t p_. \\
[style=Cempty] ~ & [name=N4,style=Cfill] \phi_.{p_.} & [style=Cempty] ~
% node connections
\psset{nodesep=5pt,arrows=->}
\ncline[linecolor=red,linewidth=.05cm]{N1}{N2}
\nbput*[nrot=0]{\textbf{?}}
\ncline[linestyle=dashed]{N1}{N3}
\ncline[linestyle=dashed]{N1}{N4}
\ncline[linestyle=dashed]{N2}{N4}
\ncline[linecolor=red,linewidth=.05cm]{N3}{N4}
\naput*[nrot=0]{\textbf{?}}
\endpsmatrix
$
}
\end{figure}
Using \texttt{Circle}, in order to control radius of the nodes:
\begin{figure}[H]
\centering
\newpsstyle{Cempty}{fillstyle=solid,mnode=none}
\newpsstyle{Cfill}{fillstyle=solid,fillcolor=blue!7,shadow=false}
\rule[1.8cm]{0.0pt}{3.0cm}
\psscalebox{0.935}{
$
\psmatrix[colsep=1cm,rowsep=1cm,
arrowscale=1.5,mnode=Circle,radius=0.55cm]
[style=Cempty] ~ & [name=N1,style=Cfill] \phi_tp_t & [style=Cempty] ~\\
[name=N2,style=Cfill] \phi_. p_t & [style=Cempty] ~ & [name=N3,style=Cfill] \phi_t p_. \\
[style=Cempty] ~ & [name=N4,style=Cfill] \phi_.{p_.} & [style=Cempty] ~
% node connections
\psset{nodesep=5pt,arrows=->}
\ncline[linecolor=red,linewidth=.05cm]{N1}{N2}
\nbput*[nrot=0]{\textbf{?}}
\ncline[linestyle=dashed]{N1}{N3}
\ncline[linestyle=dashed]{N1}{N4}
\ncline[linestyle=dashed]{N2}{N4}
\ncline[linecolor=red,linewidth=.05cm]{N3}{N4}
\naput*[nrot=0]{\textbf{?}}
\endpsmatrix
$
}
\end{figure}
\end{document}
答案1
似乎\Circlenode
以基線為中心,而不是內容的中心。解決方法是將內容放入 \raisebox{\depth}
.這很乏味,但你可以定義一個快捷巨集:
\documentclass[10pt,letterpaper,oneside]{article}
\usepackage[dvips,top=1.2in,bottom=0.65in,left=1.0in,right=1.0in,includefoot]{geometry}
\usepackage{pstricks-add,pst-func,}
% set up float for putting figures where you want them \usepackage{float}
\begin{document}
Using \texttt{circle}:
\begin{figure}[H]
\centering
\newpsstyle{Cempty}{fillstyle=solid,mnode=none}
\newpsstyle{Cfill}{fillstyle=solid,fillcolor=blue!7,shadow=false}
\rule[1.8cm]{0.0pt}{3.0cm}
\psscalebox{0.935}{
$
\psmatrix[colsep=1cm,rowsep=1cm,
arrowscale=1.5,mnode=circle, radius = 1cm]
[style=Cempty] ~ & [name=N1,style=Cfill] \phi_tp_t & [style=Cempty] ~\\
[name=N2,style=Cfill] \phi_. p_t & [style=Cempty] ~ & [name=N3,style=Cfill] \phi_t p_. \\
[style=Cempty] ~ & [name=N4,style=Cfill] \phi_.{p_.} & [style=Cempty] ~
% node connections
\psset{nodesep=5pt,arrows=->}
\ncline[linecolor=red,linewidth=.05cm]{N1}{N2}
\nbput*[nrot=0]{\textbf{?}}
\ncline[linestyle=dashed]{N1}{N3}
\ncline[linestyle=dashed]{N1}{N4}
\ncline[linestyle=dashed]{N2}{N4}
\ncline[linecolor=red,linewidth=.05cm]{N3}{N4}
\naput*[nrot=0]{\textbf{?}}
\endpsmatrix
$
}
\end{figure}
Using \texttt{Circle}, in order to control radius of the nodes:
\begin{figure}[H]
\centering
\newpsstyle{Cempty}{fillstyle=solid,mnode=none}
\newpsstyle{Cfill}{fillstyle=solid,fillcolor=blue!7,shadow=false}
\rule[1.8cm]{0.0pt}{3.0cm}
\psscalebox{0.935}{
$
\psmatrix[colsep=1cm,rowsep=1cm,
arrowscale=1.5,mnode=Circle, radius=0.55cm]%,C
[style=Cempty] ~ &[name=N1,style=Cfill]\raisebox{\depth}{$ \phi_tp_t $} & [style=Cempty] ~\\
[name=N2,style=Cfill] \raisebox{\depth}{$ \phi_. p_t $} & [style=Cempty] ~ & [name=N3,style=Cfill] \raisebox{\depth}{$ \phi_t p_. $} \\
[style=Cempty] ~ & [name=N4,style=Cfill] \raisebox{\depth}{$ \phi_.{p_.} $} & [style=Cempty] ~
% node connections
\psset{nodesep=5pt,arrows=->}
\ncline[linecolor=red,linewidth=.05cm]{N1}{N2}
\nbput*[nrot=0]{\textbf{?}}
\ncline[linestyle=dashed]{N1}{N3}
\ncline[linestyle=dashed]{N1}{N4}
\ncline[linestyle=dashed]{N2}{N4}
\ncline[linecolor=red,linewidth=.05cm]{N3}{N4}
\naput*[nrot=0]{\textbf{?}}
\endpsmatrix
$
}
\end{figure}
\end{document}
答案2
看起來像一個錯誤,將被修復。更新您目前的 TeX 發行版。 TeXLive 從今天開始可用。如果無法更新,請使用以下修復:
\documentclass[10pt,letterpaper,oneside]{article}
\usepackage{pst-node}
\makeatletter
\def\Circlenode@ii#1{%
\begingroup
\pst@useboxpar
\pst@dima=\dimexpr\ht\pst@hbox-\dp\pst@hbox
\divide\pst@dima\tw@
\pssetlength\pst@dimb\psk@radius
\setbox\pst@hbox=\hbox{%
\Cnodeput@iv{#1}%
\pscircle(.5\wd\pst@hbox,\pst@dima){\pst@dimb}%
\box\pst@hbox}%
\ifPst@nodealign \psboxseptrue \fi
\ifpsboxsep \psCirclebox@sep \fi
\leavevmode
\ifPst@nodealign\pst@nodealign\fi
\box\pst@hbox
\endgroup}
\makeatother
\begin{document}
Using \texttt{Circle}, in order to control radius of the nodes:
\newpsstyle{Cempty}{mnode=none}
\newpsstyle{Cfill}{fillstyle=solid,fillcolor=blue!7}
%
$
\psmatrix[colsep=1cm,rowsep=1cm,arrowscale=1.5,mnode=Circle,radius=0.55cm,
emnode=p]
& [name=N1,style=Cfill] \phi_tp_t & [style=Cempty]~ \\
[name=N2,style=Cfill] \phi_. p_t & & [name=N3,style=Cfill] \phi_t p_. \\
& [name=N4,style=Cfill] \strut\phi_.{p_.} & [style=Cempty]~
% node connections
\psset{nodesep=5pt,arrows=->}
\ncline[linecolor=red,linewidth=.05cm]{N1}{N2}
\nbput*[nrot=0]{\textbf{?}}
\ncline[linestyle=dashed]{N1}{N3}
\ncline[linestyle=dashed]{N1}{N4}
\ncline[linestyle=dashed]{N2}{N4}
\ncline[linecolor=red,linewidth=.05cm]{N3}{N4}
\naput*[nrot=0]{\textbf{?}}
\endpsmatrix
$
\end{document}