我怎样才能将 minipage 和 tikzpicture 并排放置?我希望将右图居中(现在它与顶部对齐)并为其提供图形环境,以便我可以为其添加标题。此标题应仅位于右图下方。我该怎么办?
\begin{figure}
\begin{minipage}{0.6\textwidth}
\begin{algorithm}[H]
\caption{Exact Invariant Simulator} \label{alg:eisim}
\begin{algorithmic}
\FOR{$r \in \{1,2,...,R\}$}
\STATE Sample $\theta_i^{(1,r)}$ from $\theta_i\sim p(\theta_i)$
\STATE Sample $Y^{(1,r)}\sim p(\cdot|\theta_i^{(1,r)})$
\FOR{$s \in \{2,3,..,S\}$}
\STATE Sample $\theta_i^{(s,r)}$ from $\theta_i\sim K_i(\cdot|\theta_{-i}^{(s-1,r)})$
\ENDFOR
\STATE Calculate test statistic $T(\theta^{(S,r)}, Y^{(S,r)})$ \footnotemark
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{minipage}
\hspace{40pt}
\begin{tikzpicture}
\node[latent] (y) {$Y$};
\node[latent, above = of y] (theta) {$\theta$};
\edge {theta} {y}
\end{tikzpicture}
\end{figure}
答案1
这个答案的核心基本上就是我上面的评论。主要的挑战是猜测所有的 Ti钾算法的 Z 样式和选项。你真的认为这是那些试图帮助你解决问题的人的工作吗?
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
\usepackage{algorithmic}
\usepackage{caption}
\begin{document}
\begin{minipage}{0.6\textwidth}
\begin{algorithm}[H]
\caption{Exact Invariant Simulator} \label{alg:eisim}
\begin{algorithmic}
\FOR{$r \in \{1,2,...,R\}$}
\STATE Sample $\theta_i^{(1,r)}$ from $\theta_i\sim p(\theta_i)$
\STATE Sample $Y^{(1,r)}\sim p(\cdot|\theta_i^{(1,r)})$
\FOR{$s \in \{2,3,..,S\}$}
\STATE Sample $\theta_i^{(s,r)}$ from $\theta_i\sim K_i(\cdot|\theta_{-i}^{(s-1,r)})$
\ENDFOR
\STATE Calculate test statistic $T(\theta^{(S,r)}, Y^{(S,r)})$ \footnotemark
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{minipage}
\hspace{40pt}
\begin{minipage}{0.2\textwidth}
\centering
\begin{tikzpicture}[ latent/.style={circle, draw ,inner sep=4pt,align=center}]
\node[latent] (y) {$Y$};
\node[latent, above = of y] (theta) {$\theta$};
\draw (theta) edge[-latex] (y);
\node[below=8pt of y] {};
\end{tikzpicture}
\captionof{figure}{A figure}
\end{minipage}
\end{document}