练习参考中的章节编号

练习参考中的章节编号

我希望练习引用包含章节号。请注意,在下面的屏幕截图中,引用是“图 0.1”,但只有“练习 1”。我希望练习引用包含章节号,这样我就可以跨章节引用练习。

我正在使用 overleaf (pdfLaTex 2022)。提前感谢您的帮助!

在此处输入图片描述

\documentclass[]{scrbook}

\usepackage{exercise}
\renewcounter{Exercise}[chapter]
\newcommand{\QuestionNB}{\bfseries\thechapter.\arabic{Question}.}
\renewcommand{\ExerciseHeader}{}

% I thought the following line should do the trick
\renewcommand{\theExercise}{\thechapter.\arabic{Exercise}}%

\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}

see exercise \ref{thisref} and figure \ref{fig}

\section{Exercises}
\begin{Exercise}
  \Question \label{thisref} \lipsum[1]
\end{Exercise}
 
\begin{figure}
    \includegraphics{figure.png}
    \label{fig}
\end{figure}
\end{document}

答案1

我明白了!我接近明白了,但正确的更新命令似乎是 theQuestion 而不是 theExercise。所以:

% this seems to do nothing:
\renewcommand{\theExercise}{\thechapter.\arabic{Exercise}}

% this one is correct:
\renewcommand{\theQuestion}{\thechapter.\arabic{Question}}

相关内容