Latex List of Figures - latex

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.

Related

latex subfigure not centered

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}

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:

How to reduce the size of captions in all figures

I want the captions of my figures and table to have the same size as \footnotesize. Is there something to put in the preambule of my document to do this?
Use the caption package to set the font key-value to footnotesize:
\documentclass{article}
\usepackage{caption}
\captionsetup{font=footnotesize}
\begin{document}
Some regular text set in \verb|\normalsize|.
\begin{table}[t]
\caption{A table using \texttt{\string\footnotesize}.}
\end{table}
\begin{figure}[t]
\caption{A figure using \texttt{\string\footnotesize}.}
\end{figure}
\end{document}
It is also possible to adjust the label and text formats individually for figures and tables separately. However, consistency is a better option here.

LaTeX hyperref link goes to wrong page

I am trying to create a reference to a float that doesn't use a caption. If I include \label{foo} within the float and reference it using \pageref{foo}, the correct page number is displayed in my pdf document but the hyperlink created by the hyperref package links to a different page (the first page of the section). If I include a caption before the label in the float, the hyperref link goes to the correct page.
Is there a way to get the hyperref link to work correctly without including a caption in the float? Or else is there a way to suppress the display of a caption so I can include one without it being shown?
Below is a minimal example. If I process it using pdflatex, I get three pages. The "figure" is shown on the second page, and the third page says, correctly, "See figure on page 2." But the hyperlink on the '2' says "Go to page 1", and if I click it it takes me to page 1.
If I put an empty \caption{} before the \label{foo}, then the hyperlink works correctly, but I don't want to show a caption for my float.
\documentclass[11pt]{memoir}
\usepackage{hyperref}
\begin{document}
some text
\clearpage
\begin{figure}
a figure
\label{foo}
\end{figure}
more text
\clearpage
See figure on page \pageref{foo}.
\end{document}
The \label command references the last invocation of \refstepcounter. \caption recognises that it is in a figure environment and calls \refstepcounter{figure}. You can call \refstepcounter by yourself.
To avoid skipping a number in the series of figures, you may create an own, meaningless counter with \newcounter{dummy}. The result:
\documentclass{scrreprt}
\usepackage{hyperref}
\newcounter{dummy}
\begin{document}
\chapter{First}
\newpage
\begin{figure}
{\Huge FIGURE}
\refstepcounter{dummy}
\label{fig:figure}
\end{figure}
\chapter{Second}
Goto \pageref{fig:figure}
\end{document}
Creates an hyperlink to the end of the figure. (works on my machine :-)
Note than \ref{fig:figure} is meaningless.
Right before the label, use \phantomsection, like so:
\documentclass{memoir}
\usepackage{hyperref}
\begin{document}
some text
\clearpage
\begin{figure}
a figure
\phantomsection
\label{foo}
\end{figure}
more text
\clearpage
See figure on page \pageref{foo}.
\end{document}
:)
Loading the caption package should suppress caption output of empty captions. The labels for floats are always determined by the caption command preceding the label command.

Latex: center text within listing

How do I center text within a listing in Latex?
Or another way not using listing. (Need a box with monospace font)
The answer given at tex.stackexchange is:
\documentclass{article}
\usepackage{listings}
\renewcommand{\figurename}{Listing}
% replace figurename with the text that should preceed the caption
\begin{document}
\begin{figure}[thp] % the figure provides the caption
\centering % which should be centered
\caption{Ausgabe des C-Programms}
\begin{tabular}{c} % the tabular makes the listing as small as possible and centers it
\begin{lstlisting}[label={gtt_c_ausgabe}]
printf("Your code goes here.\n");
\end{lstlisting}
\end{tabular}
\end{figure}
\end{document}
...which still leaves me wondering:
Using a frame around the code, e.g. using \lstset{frame=single,frameround=tttt}, places the frame way over to the right. How can this be avoided?
What does the renewcommand bit do?
I don't have an answer for the listing package on top of my head, but you could try the following:
\framebox[.9\linewidth]{\parbox{.85\linewidth}{\tt Hello World\\Second line}}
That produces a box with 90% of the line width, with text of width 85% of line width.
If you want it centered you just put \centering in front of the \tt command:
\framebox[.9\linewidth]{\parbox{.85\linewidth}{\centering \tt Hello World\\Second line}}
If you prefer the box without a frame, simply change \framebox into \makebox (and keep the arguments as they stand).

Resources