latex subfigure not centered - latex

My code is as following but my figures are not centre aligned with captions. How can I fix it?
code result
\begin{figure}[H]
\centering
\begin{subfigure}{0.7\textwidth}
\includegraphics[width=4cm,height=6cm]{outwithsel.PNG}
\caption{Outliner}
\label{fig:h1}
\end{subfigure}
\begin{subfigure}{\textwidth}
\includegraphics[width=0.8\linewidth]{moveBtns.PNG}
\caption{Buttons that move selected object in 4 different directions}
\label{fig:h2}
\end{subfigure}
\caption{Kitchen is selected and can be moved to where desired}
Here somaia, that's what happens when I tried what you said. fix from comment 1

Your images have the widths 4cm and .8\textwidth, respectively. This means they are smaller than the subfigure around them. To get them centred inside the bigger subfigure, you need to repeat \centering inside the subfigure.
In addition there are missing % at the end of some of your lines. These unprotected line breaks will act like a space, and thus decentre your subfigure by a small amount (probably not noticeable, but when we are already at it...).
Unrelated to your problem: don't specify both the width and the height of the image, this will distort it. At least add keepaspectratio if you really must give both dimensions.
\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{float}
\begin{document}
\begin{figure}[H]
\centering
\begin{subfigure}{\textwidth}
\centering
\includegraphics[width=4cm,height=6cm]{example-image-duck}
\caption{Outliner}
\label{fig:h1}
\end{subfigure}%
\begin{subfigure}{\textwidth}
\centering
\includegraphics[width=.8\textwidth]{example-image-duck}
\caption{Buttons that move selected object in 4 different directions}
\label{fig:h2}
\end{subfigure}%
\caption{Kitchen is selected and can be moved to where desired}
\end{figure}
\end{document}

I think you have a problem in \texwidth, you have to choose the 0.5 textwidth for each subfigure

This will solve your problem:
\begin{figure}[H]
\centering
\includegraphics[width=.7\textwidth]{Bloch sphere.PNG}
\caption{Outliner}
\label{fig:h1}
\includegraphics[width=0.7\textwidth]{Bloch sphere.PNG}
\caption{Buttons that move selected object in 4 different directions}
\label{fig:h2}
\caption{Kitchen is selected and can be moved to where desired}
\end{figure}

Related

Caption Centered To Image Rather Than Page

There isn't exactly any code here, since I just want to centre \begin{figure} and \end{figure}'s captions to the entre of the image included rather than to the centre of the page, if i centre the image to the left, the caption still appears to the centre of the page (without using minipage as that is the only way i know to do it right now).
Here's an example:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}
\begin{figure}[h]
\includegraphics[width=0.5\textwidth]{image.png}
\caption{Caption}
\end{figure}
\end{document}
What I get from compiling it:
I want this be centered to the image itself, and not the page, without using minipage.
Here is the source image btw, just some image I found on google
One possible approach using the varwidth package:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{varwidth}
\begin{document}
\begin{figure}[h]
\begin{varwidth}{\linewidth}
\includegraphics[width=0.5\textwidth]{example-image-duck}
\caption{Caption}
\end{varwidth}
\end{figure}
\end{document}

Put two images with different height aligned to the top of the page LaTeX

I would like to create landscape document with two-column pages.
On the left side of each page is located a bigger image (covering more less the left part of page and aligned to the top of the page), on the right side is located smaller image covering about 1/3 on the right side of the page, aligned to the top and with some description below
\documentclass{book}
\usepackage[landscape]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\noindent
\begin{minipage}{0.49\linewidth}
\centering
\includegraphics[width=\linewidth]{image-3x4}
\captionof{figure}{Example picture proportion 3:4}
\end{minipage}
\hspace{0.01\textwidth}
\begin{minipage}{0.49\linewidth}
\centering
\includegraphics[width=\linewidth]{image-3x1}
\captionof{figure}{Example picture proportion 3:1}
Some extra description on the right side
\end{minipage}
\end{document}
Actual output:
Desired output:
How to create two images side-by-side aligned to the top of the page as desired?
You can use the valign key (needs the adjutsbox package):
\documentclass{book}
\usepackage[landscape]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[export]{adjustbox}
\begin{document}
\noindent
\begin{minipage}[t]{0.49\linewidth}
\centering
\includegraphics[width=\linewidth,valign=t]{example-image-duck}
\captionof{figure}{Example picture proportion 3:4}
\end{minipage}
\hspace{0.01\textwidth}
\begin{minipage}[t]{0.49\linewidth}
\centering
\includegraphics[width=\linewidth,height=1cm,valign=t]{example-image-duck}
\captionof{figure}{Example picture proportion 3:1}
Some extra description on the right side
\end{minipage}
\end{document}

How to align the note with the left side of the figure?

I am trying to put notes in the pictures of my work but the notes are getting aligned with the border of the text and not the figure. How to align the note (Fonte: Elaborated by the author (2021)) of the table with the left side of the figure?
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.35]{image.jpg}
\caption{Text tex text.}
\label{fig_intbus}
\end{center}
\fonte{Elaborated by the author (2021)..}
\end{figure}
I would like something similar to the threeparttable environment for tables but that can be used in figures. I thought about the minipage environment but I don't want to specify the width for each figure manually.
Here is an example of how to do it, defining a new caption.
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\newcommand{\fonte}[1]{\captionsetup{skip=0.5ex,position=b}\caption*{\textit{Fonte:} {#1}}}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{example-image-a}
\caption{Example image.}
\label{fig-img-a}
\fonte{Teste.}
\end{figure}
\end{document}
And the result is:

Multiple subfigures in a row in a LaTeX document

I am trying to insert four figures in a LaTeX document but if I use subfigure command, two of my figures stay in first row and the other two go to the second line. Like this :
The other solution I tried was using minipage command, but the problem with minipage is that the subfigures get normal figure caption (like Figure 1) while I would like subfigure captions like (a). See the following figure:
What I prefer is to have something like second picture but with the captions like first picture.
Your figures are too wide to fit side-by-side in one line. If multiple subfigures do not fit in one line, latex does an auto linebreak. You have to specify the width of each included graphic per subfigure such, that it will sum up to be smaller than the \textwidth parameter, i.e:
\begin{figure}
\centering
\subfigure[]{\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure[]{\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure[]{\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure[]{\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\caption{(a) blah (b) blah (c) blah (d) blah}
\label{fig:foobar}
\end{figure}
leads to
While if you set the width too high, e.g. width=0.5\textwidth leads to what I believe is your problem
Although it's been a long time since the question was asked but the solution #gehbiszumeis offered didn't work for me and I still got the normal figure caption for each subfigure. So in case anyone has still the same problem as mine here is what I did (according to this):
\begin{figure}
\centering
\begin{subfigure}{.24\textwidth}
\centering
\includegraphics[width=.95\linewidth]{FIRST IMAGE}
\caption{}
\label{SUBFIGURE LABEL 1}
\end{subfigure}
\begin{subfigure}{.24\textwidth}
\centering
\includegraphics[width=.95\linewidth]{SECOND IMAGE}
\caption{}
\label{SUBFIGURE LABEL 2}
\end{subfigure}
\begin{subfigure}{.24\textwidth}
\centering
\includegraphics[width=.95\linewidth]{THIRD IMAGE}
\caption{}
\label{SUBFIGURE LABEL 3}
\end{subfigure}
\begin{subfigure}{.24\textwidth}
\centering
\includegraphics[width=.95\linewidth]{FOURTH IMAGE}
\caption{}
\label{SUBFIGURE LABEL 4}
\end{subfigure}
\caption{FIGURE CAPTION}
\label{FIGURE LABEL}
\end{figure}
If some cannot get the subfigure's caption, like (a) (b) (c) and (d), me neither.
One solution is to replace the "[]" in "\subfigure[]" with "(a)",
just like:
\begin{figure}
\centering
\subfigure(a){\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure(b){\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure(c){\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\subfigure(d){\includegraphics[width=0.24\textwidth]{monalisa.jpg}}
\caption{(a) blah (b) blah (c) blah (d) blah}
\label{fig:foobar}
\end{figure}

Latex List of Figures

So i'm trying to hide the label in my cover image.
>\begin{figure}
>\center
>\includegraphics[scale=0.5]{universidade}
>\caption* {Mycaption}
>\end {figure}
This way it's not labeling the figure but its not showing on the list of figures
Help please ;D
You can give the caption package the option labelformat=empty to suppress the Figure 1 etc. labelling:
\usepackage[labelformat=empty]{caption}
You can use square brackets to specify the description for the figure list, and curly brackets for the actual figure caption. So I think you should be able to do the following to supress the caption but still have an entry in the figure list:
\begin{figure}
\center
\includegraphics[scale=0.5]{universidade}
\caption[Mycaption]{}
\end {figure}
There are a couple of options, depending on what yo're after exactly:
\documentclass{article}
\usepackage{graphicx}
\setcounter{topnumber}{3}% Just for this example
\begin{document}
\listoffigures
\begin{figure}
\addcontentsline{lof}{figure}{Example image A}%
\centering
\includegraphics[height=4\baselineskip]{example-image-a}
Example image A
\end{figure}
\begin{figure}
\addcontentsline{lof}{figure}{\protect\numberline{}Example image B}%
\centering
\includegraphics[height=4\baselineskip]{example-image-b}
Example image B
\end{figure}
\begin{figure}
\centering
\includegraphics[height=4\baselineskip]{example-image-c}
\caption{Example image C}
\end{figure}
\end{document}
The figure caption is added using \addcontentsline{lof}{figure}{<caption>}, where <caption> can either contain a blank \numberline{}, or just the regular caption. The above example shows the usage of either.
It would also be possible to have no label shows in the image, but have a numbered entry in the LoF using caption. But it would seem strange to have a numbered entry in the LoF and an unnumbered figure.

Resources