Reference to a section is not problematic but referencing to a chapter produces some strange spacing after the number of chapter. See attached picture:
This is my code
\documentclass[12pt,a4paper,twoside,fleqn,openright]{book}
% use quite a lot of packages
\usepackage{amsfonts,amssymb,amsmath,bm}
\usepackage{enumerate}
\usepackage[section]{placeins}
\usepackage{float}
\usepackage[slovene]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage[customcolors]{hf-tikz}
\usepackage{fancyhdr}
\usepackage{longtable}
\usepackage{hyperref}
\usepackage{ifoddpage}
\usepackage{tikz}
\usepackage{tocloft}
\usepackage{titlesec}
\usepackage{pdfpages}
\usepackage{nameref}
\usepackage{multirow}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage[numbib]{tocbibind}
\usepackage{url}
\usepackage{cite}
\usepackage{upgreek}
\usepackage[inner=30mm,
outer=25mm,
top=30mm,
bottom=25mm]{geometry}
% paragraph settings
\setlength\parindent{0pt}
\setlength{\parskip}{1.5ex plus 0.5ex minus 0.5ex}
% set equation environment indentation
\setlength{\mathindent}{0.5cm}%
% set itemize environment whitespacing and left margin
\setlist[itemize]{noitemsep,nolistsep, leftmargin=*}
% set table and figure captions
\captionsetup[table]{skip=10pt,singlelinecheck=false}
\captionsetup[figure]{justification=centering}
% set tablename to Preglednica
\AtBeginDocument{%
\renewcommand\tablename{Preglednica}
}
% command for multiline cell in table
\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}}
\newcommand{\vect}[1]{\boldsymbol{\mathbf{#1}}}
% set section and tableofcontents depth
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\def\labelitemi{--}
% accordingly format a chapter definition
\titleformat{\chapter}[display]
{\bfseries}{}{0pt}{\Huge\thechapter}
% set fancy_nohead fancy header
\fancypagestyle{fancy_nohead}{
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\chead{}
\cfoot{}
}
% assign no_header
\assignpagestyle{\chapter}{fancy_nohead}
% section and chapter formatting
\renewcommand{\thechapter}{\arabic{chapter}.\quad}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}
\renewcommand{\thesubsubsection}{\thesubsection\arabic{subsubsection}.}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
\renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}}
\renewcommand\labelenumi{(\theenumi)}
\DeclareMathOperator{\E}{\mathbb{E}}
\def\checkmark{\tikz\fill[scale=0.4](0,.35) -- (.25,0) -- (1,.7) -- (.25,.15) -- cycle;}
\begin{document}
\chapter{Test}\label{cha:test}
Something written here.
\chapter{New test}\label{cha:new_test}
Reference to Chapter \ref{cha:test} \nameref{cha:test}.
\end{document}
And one line has to be problematic because simply writing
\documentclass[12pt,a4paper,twoside,fleqn,openright]{book}
\usepackage[slovene]{babel}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\begin{document}
\chapter{Test}\label{cha:test}
Something written here.
\chapter{New test}\label{cha:new_test}
Reference to Chapter \ref{cha:test} \nameref{cha:test}.
\end{document}
is not problematic anymore.
Does anybody have an idea which of the packages is problematic or maybe knows a workaround?

\thechaptercommand to contain\quad. That's all. Remove that extra horizontal space and you're done. – TeXnician Jun 30 '17 at 12:18\renewcommand{\thechapter}{\arabic{chapter}.\quad}-- what is the purpose of this instruction, especially the\quadcomponent? – Mico Jun 30 '17 at 12:20\chapter{Test}is visible as 1.____Test. But as @TeXnician found out this also corrupts my referencing. Is there a way to keep both - my spacing in the chapters and not destroy the reference to it? – skrat Jun 30 '17 at 12:24hyperrefinstead of before? Typically,hyperrefshould be loaded last, and most definitely after sectioning and other reference packages (liketitlesec,tocloftandcaption). In some cases it's not necessary, but it's definitely preferred/advised. – Werner Jun 30 '17 at 12:37