![如何使自动引用编号与章节编号格式相匹配?](https://linux22.com/image/446912/%E5%A6%82%E4%BD%95%E4%BD%BF%E8%87%AA%E5%8A%A8%E5%BC%95%E7%94%A8%E7%BC%96%E5%8F%B7%E4%B8%8E%E7%AB%A0%E8%8A%82%E7%BC%96%E5%8F%B7%E6%A0%BC%E5%BC%8F%E7%9B%B8%E5%8C%B9%E9%85%8D%EF%BC%9F.png)
中的章节号\autoref
与文本中的章节号不匹配。
梅威瑟:
\documentclass{book}
\usepackage{titlesec}
\usepackage{hyperref}
\titleformat{\chapter}[display]%
{\filcenter\normalfont\fontsize{16}{19}\selectfont\bfseries}%
{\chaptertitlename\ \Roman{chapter}}%
{0pt}%
{\normalfont\fontsize{16}{19}\selectfont\bfseries}
\begin{document}
\chapter{Introduction}\label{chap:intro}
In \autoref{chap:intro}.
I want chapter I, not chapter 1.
\end{document}
输出:
答案1
重新定义 \thechapter 以使标签知道格式:
\documentclass{book}
\usepackage{titlesec}
\usepackage{hyperref}
\renewcommand\thechapter{\Roman{chapter}}
\titleformat{\chapter}[display]%
{\filcenter\normalfont\fontsize{16}{19}\selectfont\bfseries}%
{\chaptertitlename\ \thechapter}%
{0pt}%
{\normalfont\fontsize{16}{19}\selectfont\bfseries}
\begin{document}
\chapter{Introduction}\label{chap:intro}
In \autoref{chap:intro}.
I want chapter I, not chapter 1.
\end{document}