參考章節後縮小間距

參考章節後縮小間距

引用章節沒有問題,但引用章節會在章節編號後產生一些奇怪的空格。見附圖:

在此輸入影像描述

這是我的程式碼

\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}

一行肯定有問題,因為簡單寫

\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}

不再有問題了。

有人知道哪個軟體包有問題或知道解決方法嗎?

答案1

改變計數器的表示方式chapter是這裡的問題。也就是說,線

\renewcommand{\thechapter}{\arabic{chapter}.\quad}

導致額外的空格 (a \quad) 加到您的引用中。您很可能已重新定義,\thechapter因為您希望在實際章節標題中的章節編號與其標題之間有一些額外的空格。這可以透過您使用來實現titlesec\titleformat

\titleformat{\chapter}[display]
  {\bfseries}{}{0pt}{\Huge\thechapter.\quad}

此外,由於您的其他分段編號重新定義以 結尾.,因此對這些編號的引用也將包含一個句點.,這並不理想。相反,重新定義分層地沒有尾隨期間。而是添加尾隨句點作為分段顯示的一部分。一種方法是重新定義\@seccntformat(參見如何在節號後面加上點?):

\makeatletter
\renewcommand{\@seccntformat}[1]{#1.}
\makeatother

按層次結構,我的意思是用於\the...從屬計數器表示中的任何父計數器:

\renewcommand{\thechapter}{\arabic{chapter}}
\renewcommand{\thesection}{\thechapter.\arabic{section}}
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}

上面的命令集有點多餘,因為book無論如何這是該類別的預設命令。

答案2

你的問題是\quad你的定義中有一個(它創造水平空間)\thechapter。刪除它就完成了。如果您想在章節的行中添加一些空間,請使用titlesec或類似的套件(或參見這裡)。

更新命令的其他行\theX可能應該替換為 a \usepackage{chngcntr},然後替換為許多\counterwithin{X}{chapter}

也許你也可以重新考慮這麼多包的使用。您可能沒有使用所有這些。嘗試刪除不需要的。一個例子是float它僅真正用於提供H不應使用的浮動選項(請參閱這裡)。

相關內容