又一次更新。此代码基本上显示了我需要的内容。目前我唯一的问题是是否有办法输入我的“脚注”文本,这样每行就不必放在单独的节点中。
\documentclass[10pt]{article}
%%%% Set margins %%%%
\setlength{\textwidth}{6.25in}
\setlength{\oddsidemargin}{0in}
%%%% Packages %%%%
\usepackage[labelfont={bf}, justification=justified, singlelinecheck=false, labelsep=space]{caption}
\usepackage{here}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,shapes.geometric,positioning}
\usepackage{hyperref}
%%%% Set pdf zoom to 100% %%%%
\hypersetup{pdfstartview={XYZ null null 1.00}, pdfview={XYZ null null 1.00}}
%%%% TikZ graphics styles/commands %%%%
\tikzstyle{arr}=[-latex, black, line width=0.5pt]
\tikzstyle{doublearr}=[latex-latex, black, line width=0.5pt]
\tikzstyle{input}=[font=\small\sffamily\bfseries]
\tikzstyle{rect}=[rectangle, draw=black, font=\small\sffamily\bfseries, inner sep=9pt]
\tikzstyle{circ}=[circle, draw=black, font=\small\sffamily\bfseries, inner sep=6pt]
\tikzstyle{trigl}=[
isosceles triangle,
draw,
shape border rotate=90,
inner sep=2,
font=\small\sffamily\bfseries,
isosceles triangle apex angle=60,
isosceles triangle stretches
]
\def\onesub#1{\strut$1\rlap{$_{#1}$}$}
\begin{document}
\begin{figure}[H]
\caption{The Model with Level 1 and Level 2 Predictors}
\label{CSL12}
\begin{tikzpicture}[auto, bend angle=45]
\node[rect] (Yij) at (18, -6) {$LifeSat_{ij}$};
\node[trigl, anchor=right side] (11) at (8, -3) {\onesub{1}};
\node[rect] (Gij) at (8, -5) {$Gender_{ij}$};
\node[rect] (Aij) at (8, -7) {$AgeMar_{ij}$};
\node[rect] (AGij) at (8, -9) {$Gender_{ij} \times AgeMar_{ij}$};
\node [input] (rij) at (20.5, -6) {$r_{ij}$};
\node[trigl] (12) at (10, -1.15) {\onesub{2}};
\node[rect] (Mj) at (12.5, -1) {$YearsMar_{ij}$};
\node[circ] (B0j) at (12.5, -4.35) {$\beta_{oj}$};
\node[input] (M0j) at (13.75, -3) {$\mu_{0j}$};
\draw [arr] (B0j) to (Yij);
\draw [arr] (Gij) to node [pos=.15, font=\scriptsize] (b1) {$\beta_1$} (Yij);
\draw [arr] (Aij) to node [pos=.40] {\scriptsize$\beta_2$} (Yij);
\draw [arr] (AGij) to node [pos=.55] {\scriptsize$\beta_3$} (Yij);
\draw [arr] (rij) to node [pos=.5, above] {\scriptsize$1$} (Yij);
\draw (11.right side) to (B0j);
\draw [arr] (12) to node [pos=.25, right] {\scriptsize$\gamma_{00}$} (B0j);
\draw [arr] (Mj) to node [pos=.50, right] {\scriptsize$\gamma_{01}$} (B0j);
\draw [arr] (M0j) to node [pos=.30, left] {\scriptsize$1$} (B0j);
\draw [arr] (Mj) to node [pos=.30, right] {\scriptsize$\gamma_{11}$} (b1);
\node[inner sep=0pt, font=\footnotesize] at ([yshift=-20]current bounding box.south) (a)
{Note: $YearsMar_j$ is grand mean centered and was calculated by subtracting the sample mean from each score.};
\node[inner sep=0pt, below = 0cm of a, font=\footnotesize, xshift=38]
{$AgeMar_{ij}$ is group mean centered and was calculated by subtracting the mean for the person's gender from their score.};
\end{tikzpicture}
\end{figure}
\end{document}
根据 Harish Kumar 的回复,我编写了以下更新的代码。建议的解决方案绝对是正确的。我认为如果将标题放在顶部,该图看起来会更好,所以我将其移到了那里。我还删除了上标“a”和“b”,因为它们看起来不如我想象的那么好。我做的最后一件事是扩展出现在底部的“脚注”的文本。
现在来回答几个后续问题。1) 是否可以将图形左对齐,使其与页面左侧对齐?2) 是否可以设置“脚注”,使其成为一个整体,而不是两个单独的节点?理想情况下,文本的第二行将缩进,如下所示。文本中断的确切位置可以自动或手动设置。根据我在手册中看到的一些内容,我尝试在 TikZ 中使用“\”,但遇到了一些麻烦。
\documentclass[10pt]{article}
%%%% Packages %%%%
\usepackage[labelfont={bf}]{caption}
\usepackage{here}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,shapes.geometric,positioning}
\usepackage{hyperref}
%%%% Set pdf zoom to 100% %%%%
\hypersetup{pdfstartview={XYZ null null 1.00}, pdfview={XYZ null null 1.00}}
%%%% TikZ graphics styles/commands %%%%
\tikzstyle{arr}=[-latex, black, line width=0.5pt]
\tikzstyle{doublearr}=[latex-latex, black, line width=0.5pt]
\tikzstyle{input}=[font=\small\sffamily\bfseries]
\tikzstyle{rect}=[rectangle, draw=black, font=\small\sffamily\bfseries, inner sep=9pt]
\tikzstyle{circ}=[circle, draw=black, font=\small\sffamily\bfseries, inner sep=6pt]
\tikzstyle{trigl}=[
isosceles triangle,
draw,
shape border rotate=90,
inner sep=2,
font=\small\sffamily\bfseries,
isosceles triangle apex angle=60,
isosceles triangle stretches
]
\def\onesub#1{\strut$1\rlap{$_{#1}$}$}
\begin{document}
\begin{figure}[H]
\caption{The Model with Level 1 and Level 2 Predictors}
\label{CSL12}
\begin{center}
\begin{tikzpicture}[auto, bend angle=45]
\node[rect] (Yij) at (18, -6) {$LifeSat_{ij}$};
\node[trigl, anchor=right side] (11) at (8, -3) {\onesub{1}};
\node[rect] (Gij) at (8, -5) {$Gender_{ij}$};
\node[rect] (Aij) at (8, -7) {$AgeMar_{ij}$};
\node[rect] (AGij) at (8, -9) {$Gender_{ij} \times AgeMar_{ij}$};
\node [input] (rij) at (20.5, -6) {$r_{ij}$};
\node[trigl] (12) at (10, -1.15) {\onesub{2}};
\node[rect] (Mj) at (12.5, -1) {$YearsMar_{ij}$};
\node[circ] (B0j) at (12.5, -4.35) {$\beta_{oj}$};
\node[input] (M0j) at (13.75, -3) {$\mu_{0j}$};
\draw [arr] (B0j) to (Yij);
\draw [arr] (Gij) to node [pos=.15, font=\scriptsize] (b1) {$\beta_1$} (Yij);
\draw [arr] (Aij) to node [pos=.40] {\scriptsize$\beta_2$} (Yij);
\draw [arr] (AGij) to node [pos=.55] {\scriptsize$\beta_3$} (Yij);
\draw [arr] (rij) to node [pos=.5, above] {\scriptsize$1$} (Yij);
\draw (11.right side) to (B0j);
\draw [arr] (12) to node [pos=.25, right] {\scriptsize$\gamma_{00}$} (B0j);
\draw [arr] (Mj) to node [pos=.50, right] {\scriptsize$\gamma_{01}$} (B0j);
\draw [arr] (M0j) to node [pos=.30, left] {\scriptsize$1$} (B0j);
\draw [arr] (Mj) to node [pos=.30, right] {\scriptsize$\gamma_{11}$} (b1);
\node[inner sep=0pt, font=\footnotesize] at ([yshift=-20]current bounding box.south) (a)
{Note: $YearsMar_j$ is grand mean centered and was calculated by subtracting the sample mean from each score.};
\node[inner sep=0pt, below = 0cm of a, font=\footnotesize, xshift=20]
{$AgeMar_{ij}$ is group mean centered and was by subtracting the mean for the person's gender from their score.};
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}
需要在图表后面加几个脚注。也许这真的比我想象的要难。或者我会因为结果如此简单而感到尴尬。
下面是一个示例图。第一个脚注表明 YearsMarj 是以总均值为中心的。第二个脚注表明 AgeMarij 是以组均值为中心的。不确定这个图有没有脚注标记会更好看。如果有脚注标记,那么我会想象在 YearsMarj 旁边有一个上标“a”,在 AgeMarij 和 Gender x AgeMarij 旁边有一个上标“b”。(不过,一个上标 1 和几个上标 2 可能也一样好。)很想知道这是否容易或困难。任何帮助都将不胜感激。
\documentclass[10pt]{article}
%%%% Packages %%%%
\usepackage{here}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,shapes.geometric}
\usepackage{hyperref}
%%%% Set pdf zoom to 100% %%%%
\hypersetup{pdfstartview={XYZ null null 1.00}, pdfview={XYZ null null 1.00}}
%%%% TikZ graphics styles/commands %%%%
\tikzstyle{arr}=[-latex, black, line width=0.5pt]
\tikzstyle{doublearr}=[latex-latex, black, line width=0.5pt]
\tikzstyle{input}=[font=\small\sffamily\bfseries]
\tikzstyle{rect}=[rectangle, draw=black, font=\small\sffamily\bfseries, inner sep=9pt]
\tikzstyle{circ}=[circle, draw=black, font=\small\sffamily\bfseries, inner sep=6pt]
\tikzstyle{trigl}=[
isosceles triangle,
draw,
shape border rotate=90,
inner sep=2,
font=\small\sffamily\bfseries,
isosceles triangle apex angle=60,
isosceles triangle stretches
]
\def\onesub#1{\strut$1\rlap{$_{#1}$}$}
\begin{document}
\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[auto, bend angle=45]
\node[rect] (Yij) at (18, -6) {$LifeSat_{ij}$};
\node[trigl, anchor=right side] (11) at (8, -3) {\onesub{1}};
\node[rect] (Gij) at (8, -5) {$Gender_{ij}$};
\node[rect] (Aij) at (8, -7) {\bf$AgeMar_{ij}$};
\node[rect] (AGij) at (8, -9) {$Gender_{ij} \times AgeMar_{ij}$};
\node [input] (rij) at (20.5, -6) {$r_{ij}$};
\node[trigl] (12) at (10, -1.15) {\onesub{2}};
\node[rect] (Mj) at (12.5, -1) {$YearsMar_j$};
\node[circ] (B0j) at (12.5, -4.35) {$\beta_{oj}$};
\node[input] (M0j) at (13.75, -3) {$\mu_{0j}$};
\draw [arr] (B0j) to (Yij);
\draw [arr] (Gij) to node [pos=.15, font=\scriptsize] (b1) {$\beta_1$} (Yij);
\draw [arr] (Aij) to node [pos=.40] {\scriptsize$\beta_2$} (Yij);
\draw [arr] (AGij) to node [pos=.55] {\scriptsize$\beta_3$} (Yij);
\draw [arr] (rij) to node [pos=.5, above] {\scriptsize$1$} (Yij);
\draw (11.right side) to (B0j);
\draw [arr] (12) to node [pos=.25, right] {\scriptsize$\gamma_{00}$} (B0j);
\draw [arr] (Mj) to node [pos=.50, right] {\scriptsize$\gamma_{01}$} (B0j);
\draw [arr] (M0j) to node [pos=.30, left] {\scriptsize$1$} (B0j);
\draw [arr] (Mj) to node [pos=.30, right] {\scriptsize$\gamma_{11}$} (b1);
\end{tikzpicture}
\end{center}
\caption{The Model with Level 1 and Level 2 Predictors}
\label{CSL12}
\end{figure}
\end{document}
答案1
您可以手动将脚注添加为 tikz 图片的一部分。实际上它们不是脚注而是描述。
\documentclass[10pt]{article}
%%%% Packages %%%%
\usepackage{here}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,shapes.geometric,positioning}
\usepackage{hyperref}
%%%% Set pdf zoom to 100% %%%%
\hypersetup{pdfstartview={XYZ null null 1.00}, pdfview={XYZ null null 1.00}}
%%%% TikZ graphics styles/commands %%%%
\tikzstyle{arr}=[-latex, black, line width=0.5pt]
\tikzstyle{doublearr}=[latex-latex, black, line width=0.5pt]
\tikzstyle{input}=[font=\small\sffamily\bfseries]
\tikzstyle{rect}=[rectangle, draw=black, font=\small\sffamily\bfseries, inner sep=9pt]
\tikzstyle{circ}=[circle, draw=black, font=\small\sffamily\bfseries, inner sep=6pt]
\tikzstyle{trigl}=[
isosceles triangle,
draw,
shape border rotate=90,
inner sep=2,
font=\small\sffamily\bfseries,
isosceles triangle apex angle=60,
isosceles triangle stretches
]
\def\onesub#1{\strut$1\rlap{$_{#1}$}$}
\begin{document}
\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[auto, bend angle=45]
\node[rect] (Yij) at (18, -6) {$LifeSat_{ij}$};
\node[trigl, anchor=right side] (11) at (8, -3) {\onesub{1}};
\node[rect] (Gij) at (8, -5) {$Gender_{ij}$};
\node[rect] (Aij) at (8, -7) {\bf$AgeMar_{ij}$ $^{b}$};
\node[rect] (AGij) at (8, -9) {$Gender_{ij} \times AgeMar_{ij}$ $^{b}$};
\node [input] (rij) at (20.5, -6) {$r_{ij}$};
\node[trigl] (12) at (10, -1.15) {\onesub{2}};
\node[rect] (Mj) at (12.5, -1) {$YearsMar_j$ $^{a}$};
\node[circ] (B0j) at (12.5, -4.35) {$\beta_{oj}$};
\node[input] (M0j) at (13.75, -3) {$\mu_{0j}$};
\draw [arr] (B0j) to (Yij);
\draw [arr] (Gij) to node [pos=.15, font=\scriptsize] (b1) {$\beta_1$} (Yij);
\draw [arr] (Aij) to node [pos=.40] {\scriptsize$\beta_2$} (Yij);
\draw [arr] (AGij) to node [pos=.55] {\scriptsize$\beta_3$} (Yij);
\draw [arr] (rij) to node [pos=.5, above] {\scriptsize$1$} (Yij);
\draw (11.right side) to (B0j);
\draw [arr] (12) to node [pos=.25, right] {\scriptsize$\gamma_{00}$} (B0j);
\draw [arr] (Mj) to node [pos=.50, right] {\scriptsize$\gamma_{01}$} (B0j);
\draw [arr] (M0j) to node [pos=.30, left] {\scriptsize$1$} (B0j);
\draw [arr] (Mj) to node [pos=.30, right] {\scriptsize$\gamma_{11}$} (b1);
\node[inner sep=0pt,font=\footnotesize] at ([yshift=-1]current bounding box.south) (a) {$^{a}$grand mean centered};
\node[inner sep=0pt,below = 0cm of a,font=\footnotesize] {$^{b}$group mean centered};
\end{tikzpicture}
\end{center}
\caption{The Model with Level 1 and Level 2 Predictors}
\label{CSL12}
\end{figure}
\end{document}
附注:您可以选择使用\tikzset
而不是 obsolete \tikzstyle
。
编辑:
\documentclass[10pt]{article}
%%%% Packages %%%%
\usepackage{showframe} %%% remove in your file
\usepackage[labelfont={bf}]{caption}
\usepackage{here}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,shapes.geometric,positioning}
\usepackage{hyperref}
%%%% Set pdf zoom to 100% %%%%
\hypersetup{pdfstartview={XYZ null null 1.00}, pdfview={XYZ null null 1.00}}
%%%% TikZ graphics styles/commands %%%%
\tikzstyle{arr}=[-latex, black, line width=0.5pt]
\tikzstyle{doublearr}=[latex-latex, black, line width=0.5pt]
\tikzstyle{input}=[font=\small\sffamily\bfseries]
\tikzstyle{rect}=[rectangle, draw=black, font=\small\sffamily\bfseries, inner sep=9pt]
\tikzstyle{circ}=[circle, draw=black, font=\small\sffamily\bfseries, inner sep=6pt]
\tikzstyle{trigl}=[
isosceles triangle,
draw,
shape border rotate=90,
inner sep=2,
font=\small\sffamily\bfseries,
isosceles triangle apex angle=60,
isosceles triangle stretches
]
\def\onesub#1{\strut$1\rlap{$_{#1}$}$}
\begin{document}
\noindent X \hrulefill X
\begin{figure}[H]
\caption{The Model with Level 1 and Level 2 Predictors}
\label{CSL12}
\begin{center}
\begin{tikzpicture}[auto, bend angle=45]
\node[rect] (Yij) at (16, -6) {$LifeSat_{ij}$};
\node[trigl, anchor=right side] (11) at (8, -3) {\onesub{1}};
\node[rect] (Gij) at (8, -5) {$Gender_{ij}$};
\node[rect] (Aij) at (8, -7) {$AgeMar_{ij}$};
\node[rect] (AGij) at (8, -9) {$Gender_{ij} \times AgeMar_{ij}$};
\node [input] (rij) at (18, -6) {$r_{ij}$};
\node[trigl] (12) at (10, -1.15) {\onesub{2}};
\node[rect] (Mj) at (12.5, -1) {$YearsMar_{ij}$};
\node[circ] (B0j) at (12.5, -4.35) {$\beta_{oj}$};
\node[input] (M0j) at (13.75, -3) {$\mu_{0j}$};
\draw [arr] (B0j) to (Yij);
\draw [arr] (Gij) to node [pos=.15, font=\scriptsize] (b1) {$\beta_1$} (Yij);
\draw [arr] (Aij) to node [pos=.40] {\scriptsize$\beta_2$} (Yij);
\draw [arr] (AGij) to node [pos=.55] {\scriptsize$\beta_3$} (Yij);
\draw [arr] (rij) to node [pos=.5, above] {\scriptsize$1$} (Yij);
\draw (11.right side) to (B0j);
\draw [arr] (12) to node [pos=.25, right] {\scriptsize$\gamma_{00}$} (B0j);
\draw [arr] (Mj) to node [pos=.50, right] {\scriptsize$\gamma_{01}$} (B0j);
\draw [arr] (M0j) to node [pos=.30, left] {\scriptsize$1$} (B0j);
\draw [arr] (Mj) to node [pos=.30, right] {\scriptsize$\gamma_{11}$} (b1);
\node[inner sep=0pt,outer sep=0pt, font=\footnotesize,label={[yshift=-2ex]north west:{\footnotesize Note:}},text width=0.9\textwidth,anchor=north west] at ([yshift=-20,xshift=1cm]current bounding box.south west) (a)
{$YearsMar_j$ is grand mean centered and was calculated by subtracting the sample mean from each score.\\
$AgeMar_{ij}$ is group mean centered and was by subtracting the mean for the person's gender from their score.};
\end{tikzpicture}
\end{center}
\end{figure}
\noindent X \hrulefill X
\end{document}