How do I change the caption for a figure in Latex? - latex

I would like to change the caption from being:
Figure 1: ...
to
From left to right: ...
If I try and renewcommand the figurename, they still get numbered. This is unecessary as there is only a single image in the document.
Any suggestions?

You could also use the caption package to remove the "Figure 1:" from the \caption{} command.
\usepackage{caption}
...
\begin{figure}
\caption*{A figure}
. . .
\end{figure}

If you want to use \caption{...} to specify the caption, you can use this hack in your document:
\makeatletter
\def\#makecaption#1#2{%
\vskip\abovecaptionskip
\hb#xt#\hsize{\hfil#2\hfil}%
\vskip\belowcaptionskip}
\makeatother
With this instruction, your figures will display only what you have specified as \caption{...} and won't add any "Figure 1: " etc.

Instead of using \caption you may consider putting your own content beneath the figure's content:
\includegraphics{...}
\small
From left to right: ...

Geoff's answer is basically correct. Within a figure or table environment, you can drop the caption if you don't want numbering, and just write plain text. From the book A Guide to LaTeX, 3rd edition (p.184):
The \caption command may be omitted if numbering is unwanted, since any text included in the float environment will accompany the contents. The advantages of \caption over simple text are the automatic numbering and entries in the lists of figures and tables.

Related

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.

How to make a hyperlink navigate to the top of the figure in LaTeX when using hyperref?

I have a LaTeX document with a figure and references to it:
\begin{figure}
...
\caption{...}
\label{fig:1}
\end{figure}
\ref{fig:1}
I use the hyperref package to get hyperlinks in the resulting PDF.
However the link to the figure navigates to the caption leaving the figure itself out of the view. How can I make it navigate to the start of the figure instead without moving the caption to the top?
Add this in your preamble
\usepackage{hyperref}
\usepackage[all]{hypcap} %for going to the top of an image when a figure reference is clicked
Make sure that the \usepackage[all]{hypcap} is written after the hyperref package is imported.
To previous comment:
\usepackage{hyperref}
\usepackage{caption}
is slightly better than \usepackage[all]{hypcap} because when you use e.g. figure without captions there won't be a compilation problem. The caption package by default sets option
hypcap=true
anchoring hyperlinks to the beginning of an environment.
\usepackage{hyperref}
\usepackage{caption}
Using this is a better idea than \usepackage[all]{hypcap}.

latex template or example for personal statement

I am writing a personal statement in latex. I don't want the big margin at the top of the page not big title taking a lot of space. I just like to make the layout compact but still clearly spaced with title, name and other necessary information, since there may be restriction on the number of pages. One example would be http://www.hsc.unt.edu/education/CIM/Documents/PS-Sample2_000.pdf. I wonder where to find some good latex templates or examples?
Thanks and regards!
I would use the geometry package to establish the desired margins. To get the margins in your sample document, try:
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}
Your next requirement was to fix the title block. LaTeX uses the internal command \#maketitle to format the title block. You can redefine this as you like. To achieve the same title block style as in the sample document, use:
\usepackage[svgnames]{xcolor}% provides colors for text
\makeatletter% since there's an at-sign (#) in the command name
\renewcommand{\#maketitle}{%
\begin{center}
\parskip\baselineskip% skip a line between paragraphs in the title block
\parindent=0pt% don't indent paragraphs in the title block
\textcolor{red}{\bf\#title}\par
\textbf{\#author}\par
%\#date% remove the percent sign at the beginning of this line if you want the date printed
\end{center}
}
\makeatother% resets the meaning of the at-sign (#)
The \#title, \#author, and \#date commands will print the title, author, and date. You can use whatever formatting commands you like to set the text in bold, different colors, etc.
Put all of the above commands in the preamble of the document. The preamble is the space between \documentclass and \begin{document}.
\documentclass{article}
% this is the preamble
% put all of the above code in here
\title{Personal Statement}
\author{Tim}
\begin{document}
\maketitle% prints the title block
Emergency medicine has always been a passion of mine\ldots
\end{document}
Attempt #1: I've used the following style file, which I call cramp2e, for similar purposes. It is probably not right for you, but have a look:
\oddsidemargin -1cm
\evensidemargin -2cm
\topmargin 1cm
\textheight 24cm
\textwidth 19cm
\headheight 0cm
\headsep .7cm
\footskip .7cm
\parskip .2cm
\paperheight 25cm
\setlength\voffset{-.33in}
\setlength\hoffset{-.25in}
Any good?
Postscript This is for A4 size paper.
A slightly less LaTeX-ey solution would be to not use the \maketitle command. A couple of times I've simply used this as my title(marginsize helps too).
Set up smaller margins:
\documentclass{article}
\usepackage{anysize}
\marginsize{1cm}{1cm}{1cm}{1cm}
(EDIT: 1cm might be even better..)
Minimal title:
\begin{document}
\begin{center}
\section*{My Document Title}
\today
\end{center}
% content goes here
\end{document}
The result looks something like:

LaTeX blank after number and before text

How could I make a blank after the number in my footnotes?
In a general way, for ALL footnotes!
Example:
good: 1 Hello World
bad : 1Hello World
The correct answer is not to redefine \thefootnote, because that adds space wherever the footnote is referenced; for example:
\documentclass{article}
\renewcommand{\thefootnote}{\arabic{footnote}~}
\begin{document}
hello\footnote{test\label{foo}} but don't forget about fn.\,\ref{foo}.
\end{document}
Note the extra space when the footnote number is referred to!
The footnote itself (including the number) is placed by the macro \#makefntext, whose default definition is
\parindent 1em\noindent \hb#xt# 1.8em{\hss \#makefnmark }#1
Here's an example of a replacement that adds some space after the footnote number:
\documentclass{article}
\makeatletter
\long\def\#makefntext#1{%
\parindent 1em\noindent\hb#xt# 1.8em{\hss\#makefnmark}~#1%
}
\makeatother
\begin{document}
hello\footnote{test\label{foo}} but don't forget about fn.\,\ref{foo}.
\end{document}
You might also wish to reduce the indent on the left, for example.
EDIT: Ok, redesigned. Ugly hack, but hey, isn't LaTeX just a whole bunch of those?
Put the following into your preamble:
\let\myfootnote\footnote
\renewcommand{\footnote}[1]{\myfootnote{~#1}}
This will simply prefix your footnote text automagically with a non-breaking space, therefore creating a space after the foot note mark at the bottom of the page. And it won't touch the footnote mark in the middle of the text which is why it still works properly directly before punctuation.
\hspace
can always supply horizontal spacing somewhere.
\footnote{\ insert footnote here}
\footnote{~insert footnote here}
Work, but I do not know if it is the official way to do it. The "~" is officially used in cases like:
Mr.~Smith
To provide the usual whitespace after the abbreviation "." The "\ " I do not know, I just happend to see its use some time ago after accidently putting it in a sentence.
You could try ~ a non-breakable space
I made myself an account, but now I couldn't comment the answers, so I posed my solution.
I tried Will's version, but I have problems if the footnote is to long and needed a new line.
So based on his work I find this:
\makeatletter
\renewcommand{\#makefntext}[1]{%
\setlength{\parindent}{0pt}
\begin{list}{}{%
\setlength{\topsep}{0pt}
\setlength{\partopsep}{0pt}
\setlength{\labelwidth}{1em} % Space from number to border
\setlength{\labelsep}{0.3em} % Space from number to text
\setlength{\leftmargin}{\labelwidth}
\addtolength{\leftmargin}{\labelsep}
\footnotesize}\item[{\makebox[\labelwidth][r]{\#makefnmark}}]#1%
\end{list}
}
\makeatother
Thanks for all of your help, now it is looking very nice and I haven account ;).

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}

Resources