Reputation: 143
I don't like to use an outer picture editor just like xfig, because it don't make work. Here's an example:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[magyar]{babel}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{tikz}
\usepackage{cutwin}
\newtheorem{thm}{tétel}
\begin{document}
\section{Téglalap}
\begin{thm}
A téglalap a területét az oldalhosszakból az
$$A=ab$$
képlettel számolhatjuk ki.
\end{thm}
\begin{proof}
A bizonyítás grafikusan igen jól szemléltethető. Vegyünk fel ugyanis egy $a+b$ oldalhosszúságú négyzetet, és ebben helyezzük el a négy egybevágó téglalapot.
\opencutleft\begin{cutout}{3}{0pt}{\textwidth}{1}
\begin{tikzpicture}
\draw (0,0) -- (0,1) -- (3,1) -- (3,0) -- cycle;
\draw (3,0) -- (4,0) -- (4,3) -- (3,3) -- cycle;
\draw (4,3) -- (4,4) -- (1,4) -- (1,3) -- cycle;
\draw (0,4) -- (1,4) -- (1,1) -- (0,1) -- cycle;
\end{tikzpicture}
\end{cutout}
A nagy négyzet területe $A=(a+b)^2$, a belső kis négyzet oldalhossza $a-b$, így a területe $A'=(a-b)^2$. A kettő különbsége lesz a négy téglalap területének összege:
\begin{align*}
(a+b)^2-(a-b)^2&=a^2+b^2+2ab-(a^2+b^2-2ab)=\\
&=4ab=4A.
\end{align*}
Innen egy téglalap területe az egybevágóság miatt már megkapható, és ez pont a tétel állítása.
\end{proof}
\end{document}
The problem is that the picture slips over the upper text, and the space above is empty, the begins the following text. When I alter the spaces, the picture goes evrywhere, and lowering those numbers it's getting closer the planned place, with awaiting it at the number 0. But when I write zero, the translator throws errors because of it and outs. The exact message says "Missing number, treated az zero".
Upvotes: 2
Views: 4474
Reputation: 7375
wrapfig
package does not to help inside proof
environment, so I'll post a very simple no-float alternative to the good answer by @dfri.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[magyar]{babel}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{tikz}
%\usepackage{cutwin}
\newtheorem{thm}{tétel}
\begin{document}
\section{Téglalap}
\begin{thm}
A téglalap a területét az oldalhosszakból az
$$A=ab$$
képlettel számolhatjuk ki.
\end{thm}
\begin{proof}
A bizonyítás grafikusan igen jól szemléltethető. Vegyünk fel ugyanis egy $a+b$ oldalhosszúságú négyzetet, és ebben helyezzük el a négy egybevágó téglalapot.
\begin{center}
\begin{tikzpicture}
\draw (0,0) -- (0,1) -- (3,1) -- (3,0) -- cycle;
\draw (3,0) -- (4,0) -- (4,3) -- (3,3) -- cycle;
\draw (4,3) -- (4,4) -- (1,4) -- (1,3) -- cycle;
\draw (0,4) -- (1,4) -- (1,1) -- (0,1) -- cycle;
\end{tikzpicture}
\end{center}
A nagy négyzet területe $A=(a+b)^2$, a belső kis négyzet oldalhossza $a-b$, így a területe $A'=(a-b)^2$. A kettő különbsége lesz a négy téglalap területének összege:
\begin{align*}
(a+b)^2-(a-b)^2&=a^2+b^2+2ab-(a^2+b^2-2ab)=\\
&=4ab=4A.
\end{align*}
Innen egy téglalap területe az egybevágóság miatt már megkapható, és ez pont a tétel állítása.
\end{proof}
\end{document}
outputs:
Notice that I only edited lines 25 and 32 (and commented \usepackage{cutwin}
in line 12): center
environment behaves properly also with text of arbitrary length before \section{}
.
I'll post an update if I work out some good setting for cutout
environment, which is meant to be used in theorem-like environments.
Upvotes: 0
Reputation: 73206
You're probably best off letting your tikz picture be a part of a figure, to which you can reference from your theorem. One way to achieve this is to embed your tikz picture within a savebox, e.g.:
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\newtheorem{theorem}{Theorem}
%% Define savebox and tikz picture
\newsavebox{\mytikzpic}
\begin{lrbox}{\mytikzpic}
\begin{tikzpicture}
\draw (0,0) -- (0,1) -- (3,1) -- (3,0) -- cycle;
\draw (3,0) -- (4,0) -- (4,3) -- (3,3) -- cycle;
\draw (4,3) -- (4,4) -- (1,4) -- (1,3) -- cycle;
\draw (0,4) -- (1,4) -- (1,1) -- (0,1) -- cycle;
\end{tikzpicture}
\end{lrbox}
\begin{document}
\subsection*{My TiKZ picture within a savebox}
\noindent See my TiKZ picture in Figure~\ref{fig1}.
\begin{theorem}
I have some theorem using this TiKZ picture in Figure~\ref{fig1}, which yields
\begin{align*}
x = c^2 + \sum_{i=1}^4 ab,
\end{align*}
\noindent where $a$ and $b$ are side lengths of the rectangles in Figure~\ref{fig1}, and $c$ the side length of the middle square.
%% Include savebox in a figure
\begin{figure}[h]
\centering
\usebox{\mytikzpic}
\caption{My TiKZ picture.}
\label{fig1}
\end{figure}
%
\noindent And with this, the area has been blahablasized.
\end{theorem}
\end{document}
Producing the following output:
Naturally you can move the figure outside of the theorem environment, if you so wish.
Note also that if you wish to remove the whole figure caption, just enter the figure as
\begin{figure}[h]
\centering
\usebox{\mytikzpic}
\end{figure}
In your .tex file, instead producing the following:
Upvotes: 2