tikzlibrary 无法从本地文件加载

tikzlibrary 无法从本地文件加载

因为某些原因tikz-bayesnet没有正确显示常量(第 22 行这个文件):

\tikzstyle{const} = [rectangle, inner sep=0pt, node distance=1]

以下是背面示例的链接它在前言中加载库并在项目根目录中包含源文件,但常量仍然显示没有矩形节点:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{bayesnet, fit, backgrounds, positioning, matrix,arrows.meta,calc,decorations.pathreplacing,quotes}

\title{tikz example}
\author{mkarikom }
\date{April 2021}

\begin{document}

\maketitle

\section{Introduction}


\begin{tikzpicture}[x=1.7cm,y=1.8cm]

  % Nodes

  \node[obs]                   (X)      {$X$} ; %
  \node[latent, above=of X]    (T)      {$T$} ; %
  \node[latent, above=of T]    (theta)  {$\theta$}; %
  \node[const, above=of theta] (atheta) {$\alpha_\theta$};


  % Factors
  \factor[above=of X]     {X-f}     {Multi} {} {} ; %
  \factor[above=of T]     {T-f}     {left:Multi} {} {} ; %
  \factor[above=of theta] {theta-f} {left:Dir} {} {} ; %

  % More nodes
  \node[latent, right=of X-f] (phi)  {$\phi$}; %
  \node[const, above=of phi]  (aphi) {$\alpha_\phi$}; %

  \factor[above=of phi] {phi-f} {right:Dir} {} {} ; %

  \factoredge {theta}  {T-f}     {T} ; %
  \factoredge {atheta} {theta-f} {theta} ; %
  \factoredge {phi}    {X-f}     {X} ; %
  \factoredge {aphi}   {phi-f}   {phi} ; %

  \gate {X-gate} {(X-f)(X-f-caption)} {T}

  \plate {plate1} { %
    (X)(X-gate) %
    (T)(T-f)(T-f-caption) %
  } {$\forall 1 \leq i \leq n_d$}; %
  \plate {} { %
    (plate1) %
    (theta)(theta-f)(theta-f-caption) %
  } {$\forall d \in \mathcal{D}$} ; %
  \plate {} { %
    (phi)(phi-f)(phi-f-caption) %
  } {$\forall t \in \mathcal{T}$} ; %

\end{tikzpicture}

\end{document}

答案1

您的描述有点模糊,但据我所知,您希望绘制节点的轮廓。样式rectangular中使用的选项const仅设置节点的形状。就像其他节点形状(例如)一样circle,为了实际绘制轮廓,您需要添加draw到节点样式。

假设您希望所有const节点都这样做,因此最好使用 修改样式append style,如下所示:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{bayesnet}
\tikzset{
  const/.append style={
    draw, % draw outline
    inner sep=0.333em % add some space between node contents and outline
    }
}
\begin{document}
\begin{tikzpicture}
\node[const] {$\alpha_\theta$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容