セクションの参照は問題ありませんが、章の参照は章番号の後に奇妙なスペースが生じます。添付の画像を参照してください。
これは私のコードです
\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}
そして、1行だけ書くと問題になるのは、
\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}
また、他のセクション番号の再定義は で終わるため.
、これらへの参照にもピリオドが含まれることになり.
、これは理想的ではありません。代わりに、 を再定義してください。階層的にそしてそれなし末尾のピリオドをセクション表示の一部として追加します。1つの方法は、\@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
または同様のパッケージを使用してください(または、ここ)。
そして、コマンドを更新する他の行は、おそらく aと many\theX
に置き換える必要があります。\usepackage{chngcntr}
\counterwithin{X}{chapter}
おそらく、多くのパッケージの使用法も再考する必要があるでしょう。おそらく、それらすべては使用していないでしょう。不要なものを削除してみてください。1つの例は、実際には使用すべきではない float オプションfloat
を提供するだけのものです (H
ここ)。