Overleaf: Picture Formatting - latex

I want to fit my image in the Overleaf but the output result is not as expected.
The overleaf code i used is as:
\begin{figure}[htb]
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{Fig2.png}
\label{Fig1}
\end{figure}
\begin{figure}[htb]
\includegraphics[scale=0.5]{Fig_3.png}
\label{Fig2}
\end{figure}
However my image is coming on top of the text of the other sections, any solutions are appreciated.
Note: The Image needs the whole page width to be accommodated

Try \pagebreak before and/or after images.
The next option is to replace [htb] with [!h].

Related

Add border to all images

I have a document that has a handful of figures in it, and I am using
\tcbox{\includegraphics{./Pictures/image-name.png}}
to put a border around them. I end up repeating this for every image though. Is there a way to put something at the top of my document that says to apply this to all images?
If nothing else in your document relies on \includegraphics, you could try the following redefinition:
\documentclass{article}
\usepackage[most]{tcolorbox}
\let\includegraphicsold\includegraphics
\renewcommand{\includegraphics}[2][]{\tcbox{\includegraphicsold[#1]{#2}}}
\begin{document}
\includegraphics[width=10cm]{example-image-duck}
\end{document}

How to align a picture correctly in Overleaf

I want to insert an image on my text but the image always aligns on top of the text and not below as I wanted to. Does anyone know how to accomplish this?
This is the image I want to display on the bottom
\subsection{Distribución Normal}
all that text in spanish
\begin{figure}
\centering
\centerline{\includegraphics[width=8cm,height=8cm]{fdd.eps}}
\end{figure}
If you want to specify where the figure has to be, you have to use some options of the figure environment: for example
all that text in spanish
\begin{figure}[h]
\centering
\includegraphics[width=8cm,height=8cm]{fdd.eps}
\end{figure}
means that LaTeX will try to put the figure where you inserted the figure environment ([h]ere). Other options include
t: top
b: bottom
p: on a special page only for floating environments
You can use several options, for example
all that text in spanish
\begin{figure}[htb]
\centering
\includegraphics[width=8cm,height=8cm]{fdd.eps}
\end{figure}
LaTeX will try to put the figure following the order of the options provided: first it will try to put it [h]ere, then on the [t]op and finally, if the other two possibilities are not available, it will put the figure on the [b]ottom of the page. This strategy lets LaTeX decide the best position for the figure.
For references, see this Overleaf document.

image "stuck!", using 2 column based document

I'm relatively new to LaTex and have ran into a weird problem.
I am trying to insert an image into my \documentclass[twocolumn]{article} file and it does insert but in a horrendous place.
I tried centring the image and the /newpage command but it doesn't move. the code I use to enter the image is \includegraphics[scale=1]{IMAGE ADDRESS}.
I would upload an image for you to see but I don't have enough reputation.
You should wrap your includegraphics in a figure environment:
\begin{figure}[p]
\includegraphics[scale=1]{IMAGE ADDRESS}
\end{figure}
The option p could also be
h for here
t for top
b for bottom
tb for "top if possible, bottom if it is too bad"
...
See How to influence the position of float environments like figure and table in LaTeX? for a more detailed answer.
\clearpage
\begin{figure}[p!]
\includegraphics[scale=0.4]{IMAGE ADDRESS}
\end{figure}
this fixed the problem, the main thing being \clearpage , which forces latex to start a new page

Latex - Change margins of only a few pages

I have a Latex document where I need to change the margins of only a few pages (the pages where I'm adding a lot of graphics).
In particular, I'd like to change the top margins (\voffset). I've tried doing:
\addtolength{\voffset}{-4cm}
% Insert images here
\addtolength{\voffset}{4cm}
but it didn't work. I've seen references to the geometry package, but I haven't found how to use it for a bunch of pages, and not for the whole document.
Any hints?
Use the "geometry" package and write \newgeometry{left=3cm,bottom=0.1cm} where you want to change your margins. When you want to reset your margins, you write \restoregeometry.
I've used this in beamer, but not for general documents, but it looks like that's what the original hint suggests
\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}
Then to use it
\begin{changemargin}{-1cm}{-1cm}
don't forget to
\end{changemargin}
at the end of the page
I got this from Changing margins “on the fly” in the TeX FAQ.
I was struggling a lot with different solutions including \vspace{-Xmm} on the top and bottom of the page and dealing with warnings and errors. Finally I found this answer:
You can change the margins of just one or more pages and then restore it to its default:
\usepackage{geometry}
...
...
...
\newgeometry{top=5mm, bottom=10mm} % use whatever margins you want for left, right, top and bottom.
...
... %<The contents of enlarged page(s)>
...
\restoregeometry %so it does not affect the rest of the pages.
...
...
...
PS:
1- This can also fix the following warning:
LaTeX Warning: Float too large for page by ...pt on input line ...
2- For more detailed answer look at this.
3- I just found that this is more elaboration on Kevin Chen's answer.
\par\vfill\break % Break Last Page
\advance\vsize by 8cm % Advance page height
\advance\voffset by -4cm % Shift top margin
% Start big page
Some pictures
% End big page
\par\vfill\break % Break the page with different margins
\advance\vsize by -8cm % Return old margings and page height
\advance\voffset by 4cm % Return old margings and page height
For figures you can use the method described here :
http://texblog.net/latex-archive/layout/centering-figure-table/
namely, do something like this:
\begin{figure}[h]
\makebox[\textwidth]{%
\includegraphics[width=1.5\linewidth]{bla.png}
}
\end{figure}
Notice that if you have subfigures in the figure, you'll probably want to enter into paragraph mode inside the box, like so:
\begin{figure}[h]
\makebox[\textwidth]{\parbox{1.5\textwidth}{ %
\centering
\subfigure[]{\includegraphics[width=0.7\textwidth]{a.png}}
\subfigure[]{\includegraphics[width=0.7\textwidth]{b.png}}
\end{figure}
For allowing the figure to be centered in the page, protruding into both margins rather than only the right margin.
This usually does the trick for images. Notice that with this method, the caption of the image will still be in the delimited by the normal margins of the page (which is a good thing).
A slight modification of this to change the \voffset works for me:
\newenvironment{changemargin}[1]{
\begin{list}{}{
\setlength{\voffset}{#1}
}
\item[]}{\end{list}}
And then put your figures in a \begin{changemargin}{-1cm}...\end{changemargin} environment.
Look up \enlargethispage in some LaTeX reference.
I could not find a easy way to set the margin for a single page.
My solution was to use vspace with the number of centimeters of empty space I wanted:
\vspace*{5cm}
I put this command at the beginning of the pages that I wanted to have +5cm of margin.
This worked for me:
\newpage % larger page1
\enlargethispage{1.5cm} % more room for text or floats
\advance\voffset by -0.5cm % reduce top margin
\advance\footskip by 1cm % lower page number
Some content
\newpage % larger page2
\enlargethispage{1.5cm}
Some content
...
\newpage % return to normal page
\advance\voffset by 0.5cm
\advance\footskip by -1cm
I had the same problem in a beamer presentation. For me worked using the columns environment:
\begin{frame}
\begin{columns}
\column{1.2\textwidth}
\begin{figure}
\subfigure{\includegraphics[width=.49\textwidth]{1.png}}
\subfigure{\includegraphics[width=.49\textwidth]{2.png}}
\end{figure}
\end{columns}
\end{frame}

Inserting images in LaTeX

I have a question on inserting images into a LaTeX document. I try to insert images using the keyboard short cut: Ctrl-Alt-G and I'm able to insert images. But the compiled pdf document shows all the images at the end, whereas I want to interleave images with text. Something like the following:
Text1
Image1
Text2
Image2
Text3
Image3
I try to insert images at right positions i.e. in between text, but on compilation, they all appear at the end. I have tried different options provided on the image insertion UI but same result.
Any idea where I'm going wrong.
Related SO question.
You'll have to use graphicx package:
\usepackage{graphicx}
and then you just use \includegraphics
\includegraphics{myfig.pdf}
\includegraphics[width=60mm]{myfig.png}
\includegraphics[height=60mm]{myfig.jpg}
\includegraphics[scale=0.75]{myfig.pdf}
\includegraphics[angle=45,width=52mm]{myfig.jpg}
Try downsizing the images. Maybe they are too large and so they are moved to the end of the document..
Hope it helps.
What code did you use for the \figure environment? In most cases the "h" option should at least help a little bit there.
This is a FAQ: "Moving tables and figures in LaTeX". Note especially the third dot point, which relaxes some of the restrictions LaTeX uses to position floats.
That's the best answer I can give without seeing an example of how large your floats are and how you're inserting them into the document. Provided that they're reasonably-sized, you should have no problem with
\begin{figure}[htbp]
\includegraphics{myfig}
\caption{...}
\label{fig:myfig}
\end{figure}
And note that if the float is too large to fit then it will move to a subsequent page -- this is the whole idea behind getting LaTeX to help you with the formatting. You certainly don't want to end a page prematurely just because there's a figure coming up next that otherwise doesn't fit.
Maybe this can help you in general...I just hate the LaTeX way of making everything too advanced (flexible) at all times.
Beside, the source looks really awful.
It will not solve you initial problem, but since it will be easier to change size of each image you can at least try...
% Easy image insert
% use as \img{imagename}{caption}{label}
% will insert image with with 70% of textwidth
% change below for other width
\newcommand{\img}[3]{
\begin{figure}[!ht]
\centering
\includegraphics[width=0.7\textwidth]{#1}
\caption{#2}
\label{fig:#3}
\end{figure}
}
\img{myimage}{has this caption}{and_this_label}
the label is automatically prefixed with fig:.
Good luck!
/C
Using [!t] and [!h] in the figure environment, rather than [t], [h] etc seems to help, though I've yet to find a surefire way to get large images in sensible places. Sometimes it works half way through a document, othertimes it doesn't.
Sometimes just changing the width or height using an option to the includegraphics statement (square brackets before the filename a.k.a \includegraphics[width=foo]{}) will do the trick.
\begin{figure}[H!]
\includegraphics{myfig}
\caption{...}
\label{fig:myfig}
\end{figure}
Use H! to denote that you want your picture right there.
\documentclass{article}
\usepackage{graphicx}
\begin{document}
text
\begin{figure}[tbh]
\centering
\includegraphics[width=0.4 \textheight]{ & directory path of jpg. width defines the width of the page and one one can put in its place height which is text page height }
\caption{name of the jpg}
\end{figure}
% it worked for me.
\end{document}

Resources