Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
1  
Meta: No, you would have to render it yourself and upload an image. Why doesn't maths render as maths? Oh, and welcome to TeX.sx! –  Torbjørn T. Feb 27 '13 at 19:05
1  
May be you can show us this way –  texenthusiast Feb 27 '13 at 19:18
1  
Welcome to TeX.sx! No need to add thanks in your post, simply upvote any good answers you may receive. We try to keep posts concise this way. –  Peter Jansson Feb 27 '13 at 19:20
1  
I added the image and removed the meta question about that. Hope that is ok. And for future reference, while code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill Feb 27 '13 at 19:37

1 Answer 1

up vote 6 down vote accepted

Not sure why minipage did not work for you:

enter image description here

Note:

Code:

\documentclass{article}

\usepackage{amsmath,tikz}

\usepackage{etoolbox}

% http://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}

% http://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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.