# Removing extra leading space from figure/equation numbering in text and captions

I'm currently trying to write my thesis in LaTeX and while everything else seems to be working fine, I can't seem to figure out how I could remove the leading space in the numbering of figure captions and equation references in text. I'm not that good at using LaTeX so please go easy on me if I got wrong ideas how something works. Anyways I guess LaTeX reserves space for numbering like "11.1" and that's why if my figures only go up to single numbers I get " 1.1" instead of "1.1"?

Whenever I add a figure in my text, like for example

\begin{figure}[H]
\begin{center}
\includegraphics[width=0.8\textwidth]{system}
\caption{\small Esimerkki tutkitusta...}
\label{fig:system}
\end{center}
\end{figure}


I get the kind of extra space like in my picture (note: "Kuva 4.1" = "Figure 4.1"). Within text it doesn't really matter, as I can simply do

Some text here\ref{myfig}


without a leading space before \ref command and I get the desired look for it. I guess they are all probably defined with same command but I haven't been able to find how I could change it. I tried reading documentations like the captions-package as well as searching for similar problems pretty much everywhere but with no luck.

Also with equations I'm supposed to use referencing like "In equation (2.1) this and that..." but I end up with "In equation ( 2.1) blablabla" like the bottom example of my picture ("Yhtälöä ( 2.2) ...")

$$\label{eq:soft} \begin{split} V_\alpha(\mathbf{r}) &= [1+\exp(\frac{r-R_\alpha-d}{\sigma})]^{-1}, \\ \end{split}$$
In equation (\ref{eq:soft}) bla bla bla


I know I'm supposed to add a minimal working example of my code, but considering how I'm using a rather large thesis template and I'm not really sure which commands actually affect the space in the numberings I really don't have a clue what kind of example I should really add here. I'll gladly post a minimal example if someone could at least point me to right direction.

Edit: I found the commands responsible for the numberings in my code

\renewcommand\thefigure{\ifnum\c@chapter>\z@\chapfigname.\fi\@arabic\c@figure}
\captionsetup[figure]{labelfont={bf,it},textfont={it}}
\captionsetup[subfigure]{labelfont=bf,textfont=normalfont,singlelinecheck=off,justification=raggedright}
\renewcommand \thetable{\ifnum \c@chapter>\z@ \chapfigname.\fi \@arabic\c@table}
\captionsetup[table]{labelfont={bf,it},textfont={it}}
\renewcommand \theequation{\ifnum\c@chapter>\z@\chapfigname.\fi\@arabic\c@equation}


I didn't really do anything other than comment out the lines to test how it looks without them and uncomment them again, and like magically my code seems to work now exactly as I wanted it to... :D

• Off topic: to refer an equation, you can use \eqref{} and parenthesis will be automatically inserted. – Sigur Feb 26 '18 at 21:52
• As for the Minimal Working Example, this is what I would do: First, make a copy of your stuff!! Second, remove all text and leave only what produces the problem (in this case, a figure with a caption). Then I would remove some code that I think that have nothing to do with the problem and compile. If the problem persists, I was correct, otherwise I may have found the part of the code that is causing me trouble. Repeat this last part until a MWE appears. – Phelype Oleinik Feb 26 '18 at 21:53
• We need more info on your preamble to discover why there is a blank space. This is not the default output. – Sigur Feb 26 '18 at 21:53
• You have added the space (latex does not add it) in some code that you have not shown. You need to show at least the definition of \thefigure – David Carlisle Feb 26 '18 at 22:07

You haven't shown any relevant code but it appears that you have a definition such as

\documentclass{article}

\renewcommand\thefigure{
\thesection.\arabic{figure}}

\begin{document}

\section{Zzzz}

\begin{figure}[htp]
zz

\caption{a figure\label{zz}}
\end{figure}

ZZZZZ\ref{zz}.

\end{document}


which produces

Fixing the definition not to have a space at the start of the figure counter, so changing the definition to

\renewcommand\thefigure{\thesection.\arabic{figure}}


produces

• Well thanks to you I found the commands that modified the numbering. I have no clue why it's fixed now even though I didn't really modify anything but all the same, it works! Cheers! :) – vivas Feb 27 '18 at 8:53