大家好,我正在尝试在带有 minipage 环境的框中插入 tikz 图片(组图),但名为 mybox 的节点未正确结束或关闭。我尝试设置 textwidth 参数和 minipage 大小,但不起作用。
我在下面附上了结果的图片和重现它的完整代码
完整代码:
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{url}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{esint}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{amsmath,amssymb}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\usepackage{pgfplots}
\usepackage{pst-func}
\usetikzlibrary{arrows,backgrounds,snakes}
\usepackage{amsmath}
\pgfplotsset{compat=newest}
\usetikzlibrary{patterns}
\usepgfplotslibrary{fillbetween}
\usepackage{mathtools}
\usepackage{positioning}
\usepackage{xcolor}
\makeatletter
\newcommand*\bigcdot{\mathpalette\bigcdot@{.5}}
\newcommand*\bigcdot@[2]{\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\makeatother
\title{STAT 251 Formula Sheet}
\usepackage[spanish]{babel}
\advance\topmargin-.8in
\advance\textheight3in
\advance\textwidth3in
\advance\oddsidemargin-1.45in
\advance\evensidemargin-1.45in
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}
\usepgfplotslibrary{groupplots,fillbetween}
\DeclareMathOperator{\CDF}{cdf}
\DeclareMathOperator{\PDF}{pdf}
\begin{document}
\begin{center}
{\huge{\textbf{STATS Cheatsheet\hfill {\large{\copyright}}}}}\\
\end{center}
\begin{multicols*}{2}
\tikzstyle{mybox} = [draw=black, fill=white, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=10pt]
\tikzstyle{fancytitle} =[fill=black, text=white, font=\bfseries]
%------------ Measures of Center ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{0.46\textwidth}
\begin{tabular}{lp{8cm} l}
Media:
& $\overline{x} = \frac{\sum_{i=1}^{n}x_i}{n} = \frac{x_1 + x_2 + ... + x_n}{n} $ \\
Mediana: & Si $n$ es par: $ \tilde{x} = \frac{(\frac{n}{2})^\text{th} \text{ obs.} + (\frac{n+1}{2})^\text{th} \text{ obs.}}{2} $ \\
& Si $n$ es impar: $ \tilde{x} = \frac{n+1}{2}^\text{th}\text{ obs.}$ \\
\end{tabular}
\end{minipage}
};
%------------ Measures of Center Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Medidas de Centralizaci\'on};
\end{tikzpicture}
%------------ Measures of Variability ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{0.46\textwidth}
\begin{tabular}{lp{8cm} l}
Rango: & $R = x_\text{mayor valor} - x_\text{menor valor}$\\
Varianza: & $s^2 = \frac{\sum_{i=1}^{n}(x_i - \overline{x})^2}{n-1} = \frac{\sum_{i=1}^{n}x_i^2 - n\overline{x}^2}{n-1}$\\
Desviaci\'on T\'ipica: & $s = \sqrt{\frac{\sum_{i=1}^{n}(x_i - \overline{x})^2}{n-1}} = \sqrt{\frac{\sum_{i=1}^{n}x_i^2 - n\overline{x}^2}{n-1}}$\\
IQR {\scriptsize{(interv. inter-cuart\'ilico)}:} & $\text{IQR} = \text{Q3} - \text{Q1}$
\end{tabular}\\
\textbf{C\'alculo de $\text{Q}_{(p)}$:}
\begin{itemize}
\setlength\itemsep{0em}
\item Sort data from smallest to largest: $x_{(1)} \leq x_{(2)} \leq ... \leq x_{(n)}$
\item Compute the number $np + 0.5$
\item If $np + 0.5$ is an integer, $m$, then: $\text{Q}_{(p)} = x_{(m)}$
\item If $np + 0.5$ is not an integer, $m < np + 0.5 < m+1$ for some integer $m$, then:\\ $\text{Q}_{(p)} = \frac{x_{(m)}+x_{(m+1)}}{2}$
\end{itemize}
\textbf{Valores anormales ('outliers'):}
\begin{itemize}
\setlength\itemsep{0em}
\item Values smaller than $\text{Q1} - (1.5 \times \text{IQR})$ are outliers
\item Values greater than $\text{Q3} + (1.5 \times \text{IQR})$ are outliers
\end{itemize}
\end{minipage}
};
%------------ Measures of Variability Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Medidas de Dispersi\'on};
\end{tikzpicture}
%------------ Discrete Random Variable and Distributions ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{0.46\textwidth}
Consider a \textbf{discrete} random variable $X$ \\
\textbf{Probability Mass Function} (pmf): $f(x) = P(X = x)$
\begin{enumerate}
\setlength\itemsep{0em}
\item $f(x) \geq 0$ for all $x$ in $X$
\item $\sum_x f(x) = 1$
\end{enumerate}
\textbf{Cumulative Distributive Function} (cdf): $F(x) = P(X \leq x) = \sum_{k \leq x}f(k)$ \\
\begin{tabular}{lp{8cm} l}
Mean ($\mu$): & $E(X) = \sum_{x}xf(x)$ \\
Expected value: & $E(g(X)) = \sum_{x}g(x)f(x)$ \\
Variance ($\sigma^2$): & $Var(X) = \sum_x (x-\mu)^2f(x) = E(X^2)-[E(X)]^2$\\
SD ($\sigma$): & $SD(X) = \sqrt{Var(X)}$
\end{tabular} \\
\\
\end{minipage}
};
%------------ Discrete Random Variable and Distributions Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Discrete Random Variables};
\end{tikzpicture}
%------------ Sets and Probability ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{0.46\textwidth}
\textbf{Properties of Probability:}
\begin{itemize}
\setlength\itemsep{0em}
\item \textit{General Addition Rule:} $P(A \cup B) = P(A) + P(B) - P(A \cap B)$
\item \textit{Complement Rule:} $P(A^c) = 1 - P(A)$
\item If $A \subseteq B$ then $P(A \cap B) = P(A)$
\item If $A \subseteq B$ then $P(A) \leq P(B)$
\item $P(\emptyset) = 0$ and $P(S) = 1$
\item $0 \leq P(A) \leq 1$ for all $A$
\end{itemize}
\textbf{Conditional Probability:}
\begin{itemize}
\setlength\itemsep{0em}
\item $P(A|B) = \frac{P(A \cap B)}{P(B)}$ and $P(B|A) = \frac{P(A \cap B)}{P(A)}$
\item \textit{Multiplication Rule:} $P(A \cap B) = P(B) \times P(A|B)$ and \\ $P(A \cap
B) = P(A) \times P(B|A)$
\item Events $A$ and $B$ are \textbf{independent} if and only if $P(A \cap B) =
P(A)P(B)$ \\ and thus $P(A|B) = P(A)$ and $P(B|A) = P(B)$
\end{itemize}
\begin{tabular}{l l l}
\textbf{Bayes' Theorem:}
& $P(A_i|B)$ &$= \frac{P(B|A_i)P(A_i)}{\sum_{i=1}^{n}P(A_i)P(B|A_i)}$\\
&& $= \frac{P(B|A_i)P(A_i)}{P(B|A_1)P(A_1) + P(B|A_2)P(A_2)+ . . . + P(B|A_n)P(A_n)}$\\
\end{tabular}
\end{minipage}
};
%------------ Sets and Probability Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Sets and Probability};
\end{tikzpicture}
%------------ Continuous Random Variable and Distributions ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{0.28\textwidth} %0.46
Sea $X$ una variable aleatoria \textbf{continua} \\
\textbf{Funci\'on de Densidad} (pdf):\\ $P(a \leq X \leq b) = \int_{a}^{b} f(x) dx$
\begin{enumerate}
\setlength\itemsep{0em}
\item $f(x) \geq 0$ for all $x$
\item $\int^{\infty}_{-\infty} f(x) dx = 1$
\end{enumerate}
\textbf{Cumulative Distributive Function} (cdf):\\ $F(x) = P(X \leq x) = \int_{-\infty}^{x} f(t) dt$ \\
\begin{tabular}{lp{8cm} l}
Mediana: & $x$ tal que $F(x) = 0.5$ \\
$Q_1$ y $Q_3$: & $x$ tal que $F(x) = 0.25$\\
& y $x$ tal que $F(x) = 0.75$\\
Media ($\mu$): & $E(X) = \int^{\infty}_{-\infty} xf(x) dx$ \\
Valor esperado: & $E(g(X)) = \int^{\infty}_{-\infty} g(x)f(x) dx$ \\
Varianza ($\sigma^2$): & $Var(X) = \int^{\infty}_{-\infty} (x-\mu)^2f(x) dx$\\
& \qquad\qquad$ = E(X^2)-[E(X)]^2$\\
D. T\'ipica ($\sigma$): & $DT(X) = \sqrt{Var(X)}$
\end{tabular}
\end{minipage}
\begin{minipage}{0.38\textwidth}
\vspace{-0.75cm}
\begin{tikzpicture}[thick, scale=0.77, transform canvas={scale=0.77}, declare function={%
normcdf(\x,\m,\s)=1/(1 + exp(-0.07056*((\x-\m)/\s)^3 - 1.5976*(\x-\m)/\s));
gauss(\x,\u,\v)=1/(\v*sqrt(2*pi))*exp(-((\x-\u)^2)/(2*\v^2));
}]
\begin{groupplot}[group style={group size=1 by 2},
xmin=-3,xmax=3,ymin=0,
domain=-3:3,xlabel=$x$,axis lines=middle,axis on top]
\nextgroupplot[ylabel=$\PDF(x)$,ytick=\empty,ymax=0.6]
\addplot[smooth, black,thick,name path=gauss] {gauss(x,0,1)};
\nextgroupplot[ylabel=$\CDF(x)$,ymax=1.19]
\addplot[smooth, black,thick] {normcdf(x,0,1)};
\end{groupplot}
\end{tikzpicture}
\end{minipage}
};
%------------ Continuous Random Variable and Distributions Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Continuous Random Variables};
\end{tikzpicture}
\end{document}
答案1
除了在\end{multicols*}
之前添加之外\end{document}
,将最后一个的开头更改minipage
为\begin{minipage}{0.18\textwidth}
也可以\begin{minipage}{0.38\textwidth}
解决您的问题。
为了使两个框架矩形具有相同的宽度,%
在最后两个之后添加\end{minipage}
。
续我的评论,我真诚地推荐你看一下tcolorbox
这个包。
举个tcolorbox
例子。这里tcolorbox
只使用环境,您可能也会发现这个包的库也很有用magazine
。poster
\documentclass[twocolumn]{article}
\usepackage[landscape]{geometry}
\usepackage{url}
%\usepackage{multicol}
\usepackage{amsmath}
%\usepackage{esint}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{amsmath,amssymb}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\usepackage{pgfplots}
%\usepackage{pst-func}
\usetikzlibrary{arrows,backgrounds,snakes}
\usepackage{amsmath}
\pgfplotsset{compat=newest}
\usetikzlibrary{patterns}
\usepgfplotslibrary{fillbetween}
\usepackage{mathtools}
%\usepackage{positioning}
\usepackage{xcolor}
\makeatletter
\newcommand*\bigcdot{\mathpalette\bigcdot@{.5}}
\newcommand*\bigcdot@[2]{\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\makeatother
\title{STAT 251 Formula Sheet}
\usepackage[spanish]{babel}
\advance\topmargin-.8in
\advance\textheight3in
\advance\textwidth3in
\advance\oddsidemargin-1.45in
\advance\evensidemargin-1.45in
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}
\usepgfplotslibrary{groupplots,fillbetween}
\DeclareMathOperator{\CDF}{cdf}
\DeclareMathOperator{\PDF}{pdf}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\begin{document}
{\huge{\textbf{STATS Cheatsheet\hfill {\large{\copyright}}}}}
%\begin{multicols*}{2}
\tikzstyle{mybox} = [draw=black, fill=white, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=10pt]
\tikzstyle{fancytitle} =[fill=black, text=white, font=\bfseries]
\tcbset{
my tcb box/.style={
enhanced,
attach boxed title to top left={xshift=4mm,yshift=-3mm},
boxed title style={colback=black,sharp corners},
colback=white,
fonttitle=\bfseries,
top=4mm
}
}
\begin{tcolorbox}[my tcb box, title=Medidas de Centralizaci\'on]
\begin{tabular}{lp{8cm} l}
Media: & $\overline{x} = \frac{\sum_{i=1}^{n}x_i}{n} = \frac{x_1 + x_2 + ... + x_n}{n} $ & \\
Mediana: & Si $n$ es par: $ \tilde{x} = \frac{(\frac{n}{2})^\text{th} \text{ obs.} + (\frac{n+1}{2})^\text{th} \text{ obs.}}{2} $ & \\
& Si $n$ es impar: $ \tilde{x} = \frac{n+1}{2}^\text{th}\text{ obs.}$ &
\end{tabular}
\end{tcolorbox}
\begin{tcolorbox}[my tcb box, title=Medidas de Dispersi\'on]
\begin{tabular}{lp{8cm} l}
Rango: & $R = x_\text{mayor valor} - x_\text{menor valor}$\\
Varianza: & $s^2 = \frac{\sum_{i=1}^{n}(x_i - \overline{x})^2}{n-1} = \frac{\sum_{i=1}^{n}x_i^2 - n\overline{x}^2}{n-1}$\\
Desviaci\'on T\'ipica: & $s = \sqrt{\frac{\sum_{i=1}^{n}(x_i - \overline{x})^2}{n-1}} = \sqrt{\frac{\sum_{i=1}^{n}x_i^2 - n\overline{x}^2}{n-1}}$\\
IQR {\scriptsize{(interv. inter-cuart\'ilico)}:} & $\text{IQR} = \text{Q3} - \text{Q1}$
\end{tabular}\\
\textbf{C\'alculo de $\text{Q}_{(p)}$:}
\begin{itemize}
\setlength\itemsep{0em}
\item Sort data from smallest to largest: $x_{(1)} \leq x_{(2)} \leq ... \leq x_{(n)}$
\item Compute the number $np + 0.5$
\item If $np + 0.5$ is an integer, $m$, then: $\text{Q}_{(p)} = x_{(m)}$
\item If $np + 0.5$ is not an integer, $m < np + 0.5 < m+1$ for some integer $m$, then:\\ $\text{Q}_{(p)} = \frac{x_{(m)}+x_{(m+1)}}{2}$
\end{itemize}
\textbf{Valores anormales ('outliers'):}
\begin{itemize}
\setlength\itemsep{0em}
\item Values smaller than $\text{Q1} - (1.5 \times \text{IQR})$ are outliers
\item Values greater than $\text{Q3} + (1.5 \times \text{IQR})$ are outliers
\end{itemize}
\end{tcolorbox}
\begin{tcolorbox}[my tcb box, title=Discrete Random Variables]
Consider a \textbf{discrete} random variable $X$ \\
\textbf{Probability Mass Function} (pmf): $f(x) = P(X = x)$
\begin{enumerate}
\setlength\itemsep{0em}
\item $f(x) \geq 0$ for all $x$ in $X$
\item $\sum_x f(x) = 1$
\end{enumerate}
\textbf{Cumulative Distributive Function} (cdf): $F(x) = P(X \leq x) = \sum_{k \leq x}f(k)$ \\
\begin{tabular}{lp{8cm} l}
Mean ($\mu$): & $E(X) = \sum_{x}xf(x)$ & \\
Expected value: & $E(g(X)) = \sum_{x}g(x)f(x)$ & \\
Variance ($\sigma^2$): & $Var(X) = \sum_x (x-\mu)^2f(x) = E(X^2)-[E(X)]^2$ & \\
SD ($\sigma$): & $SD(X) = \sqrt{Var(X)}$ &
\end{tabular}
\end{tcolorbox}
\newpage
\begin{tcolorbox}[my tcb box, title=Sets and Probability]
\textbf{Properties of Probability:}
\begin{itemize}
\setlength\itemsep{0em}
\item \textit{General Addition Rule:} $P(A \cup B) = P(A) + P(B) - P(A \cap B)$
\item \textit{Complement Rule:} $P(A^c) = 1 - P(A)$
\item If $A \subseteq B$ then $P(A \cap B) = P(A)$
\item If $A \subseteq B$ then $P(A) \leq P(B)$
\item $P(\emptyset) = 0$ and $P(S) = 1$
\item $0 \leq P(A) \leq 1$ for all $A$
\end{itemize}
\textbf{Conditional Probability:}
\begin{itemize}
\setlength\itemsep{0em}
\item $P(A|B) = \frac{P(A \cap B)}{P(B)}$ and $P(B|A) = \frac{P(A \cap B)}{P(A)}$
\item \textit{Multiplication Rule:} $P(A \cap B) = P(B) \times P(A|B)$ and \\ $P(A \cap
B) = P(A) \times P(B|A)$
\item Events $A$ and $B$ are \textbf{independent} if and only if $P(A \cap B) =
P(A)P(B)$ \\ and thus $P(A|B) = P(A)$ and $P(B|A) = P(B)$
\end{itemize}
\begin{tabular}{l l l}
\textbf{Bayes' Theorem:}
& $P(A_i|B)$ &$= \frac{P(B|A_i)P(A_i)}{\sum_{i=1}^{n}P(A_i)P(B|A_i)}$\\
&& $= \frac{P(B|A_i)P(A_i)}{P(B|A_1)P(A_1) + P(B|A_2)P(A_2)+ . . . + P(B|A_n)P(A_n)}$\\
\end{tabular}
\end{tcolorbox}
\begin{tcolorbox}[my tcb box, title=Continuous Random Variables, sidebyside, sidebyside align=top, righthand width=4cm, lower separated=false]
Sea $X$ una variable aleatoria \textbf{continua} \\
\textbf{Funci\'on de Densidad} (pdf):\\ $P(a \leq X \leq b) = \int_{a}^{b} f(x) dx$
\begin{enumerate}
\setlength\itemsep{0em}
\item $f(x) \geq 0$ for all $x$
\item $\int^{\infty}_{-\infty} f(x) dx = 1$
\end{enumerate}
\textbf{Cumulative Distributive Function} (cdf):\\ $F(x) = P(X \leq x) = \int_{-\infty}^{x} f(t) dt$ \\
\begin{tabular}{lp{8cm} l}
Mediana: & $x$ tal que $F(x) = 0.5$ \\
$Q_1$ y $Q_3$: & $x$ tal que $F(x) = 0.25$\\
& y $x$ tal que $F(x) = 0.75$\\
Media ($\mu$): & $E(X) = \int^{\infty}_{-\infty} xf(x) dx$ \\
Valor esperado: & $E(g(X)) = \int^{\infty}_{-\infty} g(x)f(x) dx$ \\
Varianza ($\sigma^2$): & $Var(X) = \int^{\infty}_{-\infty} (x-\mu)^2f(x) dx$\\
& \qquad\qquad$ = E(X^2)-[E(X)]^2$\\
D. T\'ipica ($\sigma$): & $DT(X) = \sqrt{Var(X)}$
\end{tabular}
\tcblower
\begin{tikzpicture}[baseline={100pt}, thick, scale=0.77, transform canvas={scale=0.77}, declare function={%
normcdf(\x,\m,\s)=1/(1 + exp(-0.07056*((\x-\m)/\s)^3 - 1.5976*(\x-\m)/\s));
gauss(\x,\u,\v)=1/(\v*sqrt(2*pi))*exp(-((\x-\u)^2)/(2*\v^2));
}]
\begin{groupplot}[group style={group size=1 by 2},
xmin=-3,xmax=3,ymin=0,
domain=-3:3,xlabel=$x$,axis lines=middle,axis on top]
\nextgroupplot[ylabel=$\PDF(x)$,ytick=\empty,ymax=0.6]
\addplot[smooth, black,thick,name path=gauss] {gauss(x,0,1)};
\nextgroupplot[ylabel=$\CDF(x)$,ymax=1.19]
\addplot[smooth, black,thick] {normcdf(x,0,1)};
\end{groupplot}
\end{tikzpicture}
\end{tcolorbox}
\end{document}