0

So I am trying to have a TikZ picture that's centered in the middle of the page and treated as a normal figure. I want text following the image as a paragraph. However, when I use the figure environment, it allocates an entire page to the image and I can't get the text I want on the same page. When I try using the wrap figure environment I get what you see below.

[![What I have now][1]][1]

\begin{wrapfigure}{c}{\textwidth}
\centering
\begin{tikzpicture}[scale=4]

\draw[ultra thick] (0,0) circle (1); \draw[thick, black!70] (0,0) -- (1,0); \node[scale=1.5] at (0.5,-0.10) {$r = 1$}; \node[scale=1.2] at (0.58,0.58) {$\frac{S_1}{2}$}; \draw[fill] (0,0) circle(0.04) node[anchor=north east, scale=2] (center) at (-0.05,0.04) {$A$};

%First polygon n=6 !=60 \node[regular polygon, regular polygon sides=6, minimum size=1cm, thick, black!60, scale=8, draw] at (0,0) {}; \foreach \i in {60,120,...,300}{ \draw[thick, black!70] (0,0) -- ({cos(\i)}, {sin(\i)} ); }

\node[scale=1.5] at ({cos(60) + 0.05}, {sin(60) + 0.1} ) {$E$}; \node[scale=1.5] at ({cos(0) + 0.1},0) {$G$}; \draw[thick, black!70] (0,0) -- ({cos(30)}, {sin(30} ) node[anchor=north west, scale=1] at ({cos(30)/2 + 0.05}, {sin(30)/2 + 0.05} ) {$a$} node[anchor=north, scale=1] at ({cos(30) - 0.02}, {sin(30)} ) {$b$} node[anchor=north, scale=1.2] at ({cos(30) + 0.1}, {sin(30) + 0.2} ) {$T$} node[anchor=north, scale=1.2] at ({cos(30) - 0.15}, {sin(30) - 0.1} ) {$F$}; \draw[thick, black!70] (0.25,0) arc (0:60:0.25); \draw[thin, black!70] ({cos(45)/4 - cos(45)/40.125}, {sin(45)/4 - sin(45)/40.125} ) -- ({cos(45)/4 + cos(45)/40.125}, {sin(45)/4 + sin(45)/40.125} ); \draw[thin, black!70] ({cos(15)/4 - cos(15)/40.125}, {sin(15)/4 - sin(15)/40.125} ) -- ({cos(15)/4 + cos(15)/40.125}, {sin(15)/4 + sin(15)/40.125} );

%n=12 !=80 \foreach \i in {0,30,...,330}{ \draw[thick, black!80] ({cos(\i)}, {sin(\i)}) -- ({cos(\i + 30)}, {sin(\i + 30)}); } \foreach \i in {30,60,...,180,240,270,...,330}{ \draw[thick, black!80] (0,0) -- ({cos(\i)}, {sin(\i)} ); } \end{tikzpicture} \caption{Circle $A$ with inscribed polygons 1 and 2} \label{fig:circ4} \end{wrapfigure}

I want the TikZ picture to be treated like a normal figure, with a paragraph following it and is centered in the middle. Should be simple right? I'm new to LaTeX and have looked all over this site for threads and found nothing that helps me with what I want. Maybe I missed a thread because I would think this would be relatively simple.

Below is pretty much what I want, but instead a TikZ drawing, not a graphic. Also, excuse the awful quality I just looked it up on google really quick to give you guys an idea.

[![Low quality example][2]][2]

Edit: So I see a lot of use the figure environment instead of wrapfigure, I tried this. What happens is whenever I use the figure environment, it sections off an entire page for the figure, so there's just half a page blank on the previous page, then no text following the image.

[![Here is what it looks like, the text appears above the image not below.][3]][3]

Edit 2: It's fixed! using \begin{figure}[H] instead of \begin{figure}[h] worked! Thanks for the help!

Zarko
  • 296,517
meek0
  • 1
  • 1
    You need to make your code compilable. There is no difference between a TikZ drawing and included graphics. If you do not want text wrapped around your figure, you should not use wrapfigure. See https://tex.stackexchange.com/questions/39017/how-to-influence-the-position-of-float-environments-like-figure-and-table-in-lat – hpekristiansen Oct 28 '20 at 18:20
  • I tried compiling this in a minimal document (just the article class, the tikz libraries necessary and some lipsum). If I put it inside a figure environment it worked fine like a regular figure, centered with the caption below. So there is something else than the image itself or the figure environment that is messing with you here. Did you have a lot of text surrounding it? If it floats to the next page and there is no text it will sort of center in the middle of the page because Latex wants to space everything nicely. So it might look like it's "taken a whole page" for it. – Plergux Oct 28 '20 at 18:27
  • I guess using simply \begin{figure} should do what you want, instead of \begin{wrapfigure}. – Harald Lichtenstein Oct 28 '20 at 21:39
  • @Plergux I updated the question, and referring specifically to the text amount, it does not matter, I have varied the text greatly and it does not matter how much I put it still sections off a whole page. – meek0 Oct 31 '20 at 21:25
  • @meek0 Do you specify where Latex should put your figures? I.e. do you write just \begin{figure} (\end{figure}) or do you specify \begin{figure}[h] (for "here") if you want the figure to appear where you place it in the text? It is also very hard to tell what is happening in your document if we don't have also the code that surrounds your problematic figure. If it is not the actual figure that is causing the problem but something else in your document (document class, packages, package settings, section formatting, ect.) that is causing the problem we can't guess from only the figure. – Plergux Oct 31 '20 at 21:34
  • @Plergux I will post the code surrounding it, as for the figure placement, it does not matter what parameter I put, no matter what it still makes a new page for it, and places the text that should be below, above on the previous page. – meek0 Nov 02 '20 at 01:20
  • 1
    @Plergux I fixed it! a capital H in the parameter worked! Thank you for your help! – meek0 Nov 02 '20 at 01:25

1 Answers1

0

First off, using \begin{figure} was what I should have been using but it didn't work at first, it had an undesired outcome. But adding a placement command fixed it. Using \begin{figure}[H] (capital H is important) fixed the issue.

Thanks for all the suggestions!

meek0
  • 1
  • With this solution you just destroy one of main features of LaTeX: migrating the floats (tables, figures) if needed, that document will look nicely. With, for example \begin{table}[ht] (not just [h]) you will obtain much better result! Please, consider @hpekristiansen comment. – Zarko Nov 02 '20 at 03:53