3

I have a tikzpicture with an accompanying explanation in a math align environment. The tikzpicture is small enough that I'd like the explanation to appear next to (specifically, to the right) the tikzpicture. Here's the code that I have:

\begin{center}
\begin{tikzpicture}[xscale=.5, yscale=.5]
\draw [->,thick] (0,0) --(3,4) node [right] {$\bar{u}$};
\draw [->,thick] (0,0) --(5,0) node [below] {$\bar{v}$};
\draw [->,thick] (0,0) --(0,4) node [left] {$\bar{w}$};
\draw [->,thick] (0,0) --(3,0) node [below] {$Pr_{\bar{v}}\bar{u}$};
\draw [dashed] (3,0) --(3,4);
\draw [thin] (2.5,0) --(2.5,.5) --(3,.5);
\end{tikzpicture}
\end{center}

\begin{align*}
Pr_{\bar{v}}\bar{u} &= \frac{\langle\bar{u},\bar{v}\rangle}{\langle\bar{v},\bar{v}\rangle}\bar{v} = \lambda\bar{v} \\
\bar{w}+Pr_{\bar{v}}\bar{u} &= \bar{u}\\
\bar{w} &= \bar{u}-Pr_{\bar{v}}\bar{u} \\
\bar{w} &= \bar{u}-\lambda\bar{v}
\end{align*}

I attempted to use minipage, multicols, and wrapfig but none produced a desirable result. This was probably due to user error since I'm pretty new at this.

It'd be helpful if someone were able to produce something close to a standard to solve this problem (if one exists).

enter image description here

Moriambar
  • 11,466
geofflittle
  • 337
  • 1
  • 10

1 Answers1

6

Not sure why minipage did not work for you:

enter image description here

Note:

Code:

\documentclass{article}

\usepackage{amsmath,tikz}

\usepackage{etoolbox}

% https://tex.stackexchange.com/questions/36954/spurious-space-above-align-environment-at-top-of-page-minipage \makeatletter \pretocmd\start@align{% \if@minipage\kern-\topskip\kern-\abovedisplayskip\fi }{}{} \makeatother

\begin{document} \begin{minipage}{0.30\linewidth} \begin{center} \begin{tikzpicture}[xscale=.5, yscale=.5] \draw [->,thick] (0,0) --(3,4) node [right] {$\bar{u}$}; \draw [->,thick] (0,0) --(5,0) node [below] {$\bar{v}$}; \draw [->,thick] (0,0) --(0,4) node [left] {$\bar{w}$}; \draw [->,thick] (0,0) --(3,0) node [below] {$Pr_{\bar{v}}\bar{u}$}; \draw [dashed] (3,0) --(3,4); \draw [thin] (2.5,0) --(2.5,.5) --(3,.5); \end{tikzpicture} \end{center} \end{minipage}% \hfill% \begin{minipage}{0.65\linewidth} \begin{align} Pr_{\bar{v}}\bar{u} &= \frac{\langle\bar{u},\bar{v}\rangle}{\langle\bar{v},\bar{v}\rangle}\bar{v} = \lambda\bar{v} \ \bar{w}+Pr_{\bar{v}}\bar{u} &= \bar{u}\ \bar{w} &= \bar{u}-Pr_{\bar{v}}\bar{u} \ \bar{w} &= \bar{u}-\lambda\bar{v} \end{align} \end{minipage}% \end{document}


Another option is to place the picture within a varwidth environment which has the advantage that you only need to tweak the size of the minipage containing the align which allows you to control how far the math content is.

enter image description here

Notes:

  • Even though the varwidth environment has a length specification, the box will adjust to the natural width of its contents.
  • You could or course use the varwidth for the math content as well, but then you don't have as much flexibility to move the math content closer to the picture (unless you use an environment different spacing than the default align.

Code:

\documentclass{article}

\usepackage{amsmath,tikz, varwidth}

\usepackage{etoolbox}

% https://tex.stackexchange.com/questions/36954/spurious-space-above-align-environment-at-top-of-page-minipage \makeatletter \pretocmd\start@align{% \if@minipage\kern-\topskip\kern-\abovedisplayskip\fi }{}{} \makeatother

\begin{document} \begin{varwidth}{\linewidth} \begin{center} \begin{tikzpicture}[xscale=.5, yscale=.5] \draw [->,thick] (0,0) --(3,4) node [right] {$\bar{u}$}; \draw [->,thick] (0,0) --(5,0) node [below] {$\bar{v}$}; \draw [->,thick] (0,0) --(0,4) node [left] {$\bar{w}$}; \draw [->,thick] (0,0) --(3,0) node [below] {$Pr_{\bar{v}}\bar{u}$}; \draw [dashed] (3,0) --(3,4); \draw [thin] (2.5,0) --(2.5,.5) --(3,.5); \end{tikzpicture} \end{center} \end{varwidth}% \begin{minipage}{0.5\linewidth} \begin{align} Pr_{\bar{v}}\bar{u} &= \frac{\langle\bar{u},\bar{v}\rangle}{\langle\bar{v},\bar{v}\rangle}\bar{v} = \lambda\bar{v} \ \bar{w}+Pr_{\bar{v}}\bar{u} &= \bar{u}\ \bar{w} &= \bar{u}-Pr_{\bar{v}}\bar{u} \ \bar{w} &= \bar{u}-\lambda\bar{v} \end{align} \end{minipage}% \end{document}

Peter Grill
  • 223,288