dealing with large figures in Latex - latex

I have a large figure that appears at the end of my document rather than in the section that I want to be in. Even \begin{figure}[h] doesn't help. Without scaling it down, how can I put it at the end of the section I want it in?

Using the afterpage package can be a good solution. However, using the option here you are trying to tell LaTeX where you want to put the image. Instead, you need to tell LaTeX where the image is good to be put:
use \begin{figure}[tb] for figures that fit well in a page with text (say, half of the text height for the figure and the other half for the text)
use \begin{figure}[p] for floats large enough to require a dedicated page.
Setting a proper option increase your chances to have the image almost where you want, having at the same time a good page layout.
If the figure is still too far from the page where it should be placed, you can set some "barriers" for floats positioning with the packages placeins or afterpage (already mentioned).

Here is a small tutorial for float placement. The thing you want to do is put an \afterpage{\clearpage} command at the end of the section. This will create an additional page after the current one and place the floats that are left in the queque there. If the float still doesn't get placed, you have to resize it. If you really don't want to resize it and it should fit on the page, then you could try changing the margins and text area temporarily (i.e. just for that one page) and see if that lets the float get placed.

i forget if it's the float or array package that provides this, but,
\begin{figure}[H]
...
\end{figure}
The upper case H will put the figure exactly where it is in your code.

Related

How to place the figure at the bottom of page in latex?

I am having problem in placing the figure at the bottom of page in latex. When I specify the \begin{figure*}[b], all the figures in my documents goes at the end of document. What I need is just place one specific figure at the bottom of current page or next page.
Please guide me how can I do this?
In order to place a float at the bottom of a two-column document, you can use the dblfloatfix package. From the brief package description:
The pack­age solves two prob­lems: floats in a twocol­umn doc­u­ment come out in the right order and al­lowed float po­si­tions are now [tbp].
So, after \usepackage{dblfloatfix} you can use
\begin{figure*}[btp]
% <your figure here>
\end{figure*}
Like will all floats (especially in a two-column environment), the float may not end up where it is placed. As such, you may have to move around the figure* declaration to achieve the desired location within your document.
stfloats provides a similar functionality.
Reference: Put a table* at the bottom of a page?
Werner's solutions didn't actually work for me.
So I just used this -
\begin{figure*}[b]
% <your figure here>
\end{figure*}
source: https://www.overleaf.com/learn/latex/Positioning_of_Figures
Using \begin{figure*}[!b] worked for me.

How to place a wide figure with subfigures in Latex?

I am trying to write a report and stuck with a wide figure. My document type is PRL using revtex4.1 with two columns. I have a wide figure which consists of 8 subfigures. I am trying to place it bottom of a page but it insists to go next page. Here is code for my wide figure:
\begin{figure*}
\centering
\subfloat[s1]{\label{fig:s1}\includegraphics[width=0.20\textwidth]{s1.png}}\qquad
\subfloat[s2]{\label{fig:s2}\includegraphics[width=0.20\textwidth]{s2.png}}\qquad
\subfloat[s3]{\label{fig:s3}\includegraphics[width=0.20\textwidth]{s3.png}}\qquad
\subfloat[s4]{\label{fig:s4}\includegraphics[width=0.20\textwidth]{s4.png}}\\
\subfloat[s5]{\label{fig:s5}\includegraphics[width=0.20\textwidth]{s5.png}}\qquad
\subfloat[s6]{\label{fig:s6}\includegraphics[width=0.20\textwidth]{s6.png}}\qquad
\subfloat[s7]{\label{fig:s7}\includegraphics[width=0.20\textwidth]{s7.png}}\qquad
\subfloat[s8]{\label{fig:s8}\includegraphics[width=0.20\textwidth]{s8.png}}
\caption{\label{fig:s}Caption}
\end{figure*}
Try also
\begin{figure*}[!hb]
If your figure is too wide, this might help: Centering wide tables or figures.
I don't know whether it will work, but have you tried using placements, ie:
\begin{figure*}[b]
where b stands for bottom?
You could also try using the float package (put this in the preamble, before \begin{document}:
\usepackage{float}
and then using
\begin{figure*}[H]
to specify exactly where you want your figure to be, i.e. put the figure exactly in the position in relation to your text where you want the figure to be placed.
It may be that your figure is just too big and it won't fit there, so you may have to reduce the size of the figures or fiddle with the margins (not recommended, but possible).
Lastly, in 6 days the LaTeX question and answer website will be open to everyone, and you might find it useful.

The way to find out whole picture width in PGF (Latex)

I've got a latex macro that draws a picture using PGF and Tikz according to given parameters. The width of picture drawn depends on these parameters.
PGF automatically calculates the resulting width of any picture drawn so the user does not have to set it explicitly(like for example when using latex build in picture environment).
However I need to know the width of picture that will be drawn. Of cause I could calculate it as the PGF does but this is going to be quite some work(a lot of if statements...). Is there a way to ask PGF what is the width of picture that is to be drawn (some command I expect)? Either inside tikzpicture environment or just after it?
Thanks for help.
What I would probably do is put the tikzpicture environment in a box, and then find the width of the box:
\setbox0=\vbox{\hbox{%
\begin{tikzpicture}
% ...
\end{tizpicture}%
}}
The width of the following picture is {\the\wd0}.
\box0
Note that after you run \box0, the box will be inserted into the document and its contents will be destroyed; you thus need to query the width of the box before you do that. If you want to save the width, you can store it in a dimension register with \dimen0=\wd0; alternatively, you can use \copybox0, which inserts the box but doesn't destroy it (although this might leak memory).
Also, having played with some of this before, I found that using just a \vbox caused the box to always be the full width of the page (which, if you think about it, makes sense); however, using just an \hbox caused the unboxing to fail for some reason (it seemed to be a known pug). Using both like this works, however—I'm using something very much like this to render TikZ pictures to PDF files of precisely the right size.

Is there a way to get LaTeX to place figures in the same page as a reference to that figure?

I am using LaTeX and the figure environment.
I am well familiar with the parameters to that environment: [htbp], and I am also generally familiar with the strategies that LaTeX takes, by default, to decide where to put each figure. For example, by placing figures at the top or bottom of the page.
What I am wondering is whether there is a package, macro, or some commands that I can give so that if I have a single-column document and I mostly have a single in-text reference to a figure, that the figure would be more likely to be placed in the same page of the reference?
For example, imagine that I have a long paragraph which in the middle has a \ref{FIG:X}. When rendered, some of the paragraph appears before the page break, and some appears after the page break. I can also place the figure command somewhere before and after the whole paragraph. Is there a way to get it to actually be placed in the same page as the actual reference?
I don't want to sound too negative, but there are occasions when what you want is almost impossible without a lot of "artificial" tuning of page breaks.
If the callout falls naturally near the bottom of a page, and the figure falls on the following page, moving the figure back one page will probably displace the callout forward.
I would recommend (as far as possible, and depending on the exact size of the figures):
Place the figures with [t] (or [h] if you must)
Place the figures as near as possible to the "right" place (differs for [t] and [h])
Include the figures from separate files with \input, which will make them much easier to move around when you're doing the final tuning
In my experience, this is a big eater-up of non-available time (:-)
In reply to Jon's comment, I think this is an inherently difficult problem, because the LaTeX guys are no slouches. You may like to read Frank Mittelbach's paper.
Yes, include float package into the top of your document and H (capital H) as a figure specifier:
\usepackage{float}
\begin{figure}[H]
.
.
.
\end{figure}
You can always add the "!" into your float-options. This way, latex tries really hard to place the figure where you want it (I mostly use [h!tb]), stretching the normal rules of type-setting.
I have found another solution:
Use the float-package. This way you can place the figures where you want them to be.
I solve this problem by always using the [h] option on floats (such as figures) so that they (mostly) go where I place them. Then when I look at the final draft, I adjust the location of the float by moving it in the LaTeX source. Usually that means moving it around the paragraph where it is referenced. Sometimes I need to add a page break at an appropriate spot.
I've found that the default placement of floats is reasonable in LaTeX, but manual adjustments are almost always needed to get things like this just right. (And sometimes it isn't possible for everything to be perfect when there are lots of floats and footnotes.)
The manual for the memoir class has some good information about how LaTeX places floats and some advice for manipulating the algorithm.
If you want force this behaviour on all of your figures try
...
\usepackage{float}
\floatplacement{figure}{H}
...
Maybe this will help you?
\begin{center}
\includegraphics[scale=0.5]{picture_name}
\end{center}
I think is better to use the graphics command when your figures run away.
I have some useful comments. Because I had similar problem with location of figures.
I used package "wrapfig" that allows to make figures wrapped by text.
Something like
...
\usepackage{wrapfig}
\usepackage{graphicx}
...
\begin{wrapfigure}{r}{53pt}
\includegraphics[width=53pt]{cone.pdf}
\end{wrapfigure}
In options {r} means to put figure from right side. {l} can be use for left side.
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\textfraction}{0.15}
\renewcommand{\floatpagefraction}{0.7}
http://robjhyndman.com/researchtips/latex-floats/
One way I found that helps with this is to use \include{file_with_tex_figure_commands}
(not input)

How do I prevent LaTeX from padding spaces between paragraphs so that next section begins at top of next page?

I have a two-column paper where space restrictions are very tight.
I just looked at my last version of the manuscript and saw that the upper half contains a figure (as expected), but in the lower half there is a lot of vertical space between paragraphs (enough to squeeze 10 more lines), and that LaTeX probably added it so that in the beginning of the next page a new numbered section will begin at the top of the page.
I know there's a way to adjust this so LaTeX doesn't try so hard, but I'm not sure how. any help? Thanks!
The parameter that controls inter-paragraph spacing is called \parskip(See Paragraph Spacing ). You set it (with "rubber" values) using something like:
\setlength{\parskip}{1cm plus4mm minus3mm}
The defualt value of \parskip is class dependent. The "plus" and "minus" parts tell TeX how much it can adjust the value to improve the layout (that is they make the spacing elastic, thus the "rubber" designation). Reducing (or eliminating) the "plus" part of the rubber might help.
Watch out though, you can cause other layout artifacts if you constrain TeX too much.
Other things to think about:
The widow and club penalties probably apply section headings, and may be affecting TeX's layout choices (see https://stackoverflow.com/questions/512967/how-can-one-keep-a-section-from-being-at-the-end-of-a-page-in-latex for a discussion).
You may also want to consider messing with \baselineskip which controls the allowed spacing between lines of text and can also have rubber values.
This is a common problem, and there are probably some fairly sophisticated treatments already prepared on CTAN.
\vfill before the new section worked perfectly for me.

Resources