[Tex/LaTex] Why is the resized box indented despite \noindent

indentationresizetikz-pgf

I'm not able to avoid indentation of my tikzpicture inside a resized box.

I've put \noindent everywhere but the figure is still indented.

Maybe it's a stupid mistake but I can't fix it.

\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[british]{babel}
\usepackage{blindtext}
\usepackage{makecell}

\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=3cm,bmargin=3.5cm,lmargin=4cm,rmargin=3cm,marginparwidth=70pt}

\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=period,format=hang,indention=0cm]{caption}

\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{calc, intersections}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{mindmap,trees}
\usetikzlibrary{positioning}
\pgfplotsset{compat=newest}

\begin{document}
\blindtext

\noindent\begin{figure}[!t]
\noindent\resizebox{\textwidth}{!}{%
\tikzset{root concept/.append style={font=\huge}}
\tikzset{level 1 concept/.append style={sibling angle=120, font=\small, minimum size=3cm, level distance=140pt}}
\tikzset{level 2 concept/.append style={sibling angle=60, font=\scriptsize, minimum size=2cm, level distance=100pt}}
\tikzset{level 3 concept/.append style={sibling angle=60, font=\tiny, minimum size=1.3cm, level distance=70pt}}
\tikzset{concept/.append style={fill={none}, text width=}}
\noindent\begin{tikzpicture}
\path[mindmap, concept color=gray!30, text=black]%
    node [concept] {\textbf{Quack}}
    [clockwise from=0]
    child { node [concept] {\makecell*{\textbf{Ducks}\\ \textbf{and ducks}}}
            [clockwise from=60]
            child { node  [concept] {\makecell*{Papere\\ Little ducks}}
                [clockwise from=90]
                child { node [concept] {Paperine}}
                child { node [concept] {Ducks}}
                }
            child { node [concept] {\makecell*{Papere\\ Funny ducks}}
               [clockwise from=30]
                child { node  [concept] {Paperine}}
                child { node [concept] {Ducks}}
                }
            child { node  [concept] {\makecell*{Papere\\ Pretty ducks}}
               [clockwise from=-30]
                child { node [concept] {Paperine}}
                child { node  [concept] {Ducks}}
              }
            }
  child { node [concept] {\makecell*{\textbf{Mallards}\\ \textbf{and mallards}}}}
  child { node [concept] {\makecell{\textbf{Geese}\\ \textbf{and geese}}}}
;
\end{tikzpicture}
}%
\caption{\label{fig:test}Test figure.}
\end{figure}
\end{document}

enter image description here

Best Answer

By default, paragraph indentation is 0pt inside a float so the \noindent inside are doing nothing, the \noindent before the \begin{figure} is completely wrong and will force the creation of a "white" paragraph that looks like vertical space.

The horizontal shift was not due to indentation but to extra space characters added after each of the \tikzset (and there was an additional space at the end of the \resizebox).

Note I left the option as [!t] but this is very restrictive as it does not allow the float to be placed on a float page, so makes it harder for latex to find a good place. It is almost always better to include p or simply not have the option.

\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[british]{babel}
\usepackage{blindtext}
\usepackage{makecell}

\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=3cm,bmargin=3.5cm,lmargin=4cm,rmargin=3cm,marginparwidth=70pt}

\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=period,format=hang,indention=0cm]{caption}

\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{calc, intersections}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{mindmap,trees}
\usetikzlibrary{positioning}
\pgfplotsset{compat=newest}

\begin{document}
\blindtext

%\noindent
\begin{figure}[!t]
%\noindent
\resizebox{\textwidth}{!}{%
\tikzset{root concept/.append style={font=\huge}}%
\tikzset{level 1 concept/.append style={sibling angle=120, font=\small, minimum size=3cm, level distance=140pt}}%
\tikzset{level 2 concept/.append style={sibling angle=60, font=\scriptsize, minimum size=2cm, level distance=100pt}}%
\tikzset{level 3 concept/.append style={sibling angle=60, font=\tiny, minimum size=1.3cm, level distance=70pt}}%
\tikzset{concept/.append style={fill={none}, text width=}}%
%\noindent
\begin{tikzpicture}
\path[mindmap, concept color=gray!30, text=black]%
    node [concept] {\textbf{Quack}}
    [clockwise from=0]
    child { node [concept] {\makecell*{\textbf{Ducks}\\ \textbf{and ducks}}}
            [clockwise from=60]
            child { node  [concept] {\makecell*{Papere\\ Little ducks}}
                [clockwise from=90]
                child { node [concept] {Paperine}}
                child { node [concept] {Ducks}}
                }
            child { node [concept] {\makecell*{Papere\\ Funny ducks}}
               [clockwise from=30]
                child { node  [concept] {Paperine}}
                child { node [concept] {Ducks}}
                }
            child { node  [concept] {\makecell*{Papere\\ Pretty ducks}}
               [clockwise from=-30]
                child { node [concept] {Paperine}}
                child { node  [concept] {Ducks}}
              }
            }
  child { node [concept] {\makecell*{\textbf{Mallards}\\ \textbf{and mallards}}}}
  child { node [concept] {\makecell{\textbf{Geese}\\ \textbf{and geese}}}}
;
\end{tikzpicture}%
}%
\caption{\label{fig:test}Test figure.}
\end{figure}
\end{document}