cleveref 引用中不需要的标点符号

cleveref 引用中不需要的标点符号

我用cleveref它来引用。有一组问题(可以是项目)及其子问题,当引用它们的标签时,我希望它们显示为“问题 1.1”或(最好)“子问题 2.3”。

tasks但是我看不出有办法命名与关联的计数器\crefname。我可以忍受,只要子问题的标点符号不妨碍。

这是我的 MWE 和一张解释这一切的图片。

\documentclass{article}
\usepackage{tasks,cleveref,xsim}

\crefname{exercise}{question}{questions}

% what should be the correct counter here, nothing seems to work
\crefname{tsk}{subquestion}{subquestions}
\crefname{subquestion}{subquestion}{subquestions}
\crefname{subquestionn}{subquestion}{subquestions}
\crefname{tsk[1]}{subquestion}{subquestions}

% type of subquestions
\NewTasks[counter-format = tsk[1]),label-format = \itshape]{parts}[\subquestion](2)
\NewTasks[counter-format = (tsk[1]*,label-format = \itshape]{follow}[\subquestionn](2)

% a hack just to get subquestion referencing
\newcommand{\refsubq}[1]{\cref{#1}.\ref{#1}}

\begin{document}
    
    \begin{exercise}
        what is the name of the game? \label{game}
        \begin{parts}
            \subquestion who plays the game? \label{game1}
            \subquestion do they all lose? \label{game2}
        \end{parts}
    \end{exercise}
    
    \begin{exercise}
        what is the game? \label{name}
        \begin{follow}
            \subquestionn is it real? \label{name1}
            \subquestionn have you played it? \label{name2}
        \end{follow}
    \end{exercise}
    
    \section*{References}
    
    \noindent Refer exercise basic = \ref{name}
    
    \noindent Refer exercise cleverref = \cref{game}
    
    \noindent Refer subquestion basic = \ref{game1}
    
    \noindent Refer subquestion cleverref = \cref{game1} % ideally I want it to output "subquestion 1.1"
    
    \noindent Refer subquestion refsubq = \refsubq{name2}
    
\end{document}

我的疑问是

  1. 如何\cref在引用子问题时打印“子问题”,在引用问题时打印“问题”?实际上,我想摆脱\refsubq
  2. counter-format如何在打印输出时去掉标点符号\cref。MWE 和图片很好地解释了这一点?

这不是 -package 的问题。我发现withinxsim也有同样的行为。\item\item

在此处输入图片描述

答案1

您只需

  • 最新tasks(自 2020/05/11 起),
  • 告诉cleveref使用计数器task
  • ref定义新环境时相应地设置选项tasks

以下是您的 MWE 的改编版:

\documentclass{article}
\usepackage{tasks,cleveref,xsim}

\crefname{exercise}{question}{questions}
\crefname{task}{subquestion}{subquestions}

% type of subquestions
\newcommand*\Star{*}
\NewTasksEnvironment[
  label = \arabic*),
  ref = \theexercise.\arabic*) ,
  label-format = \itshape ,
  label-width = 15pt
  ]{parts}[\subquestion](2)
\NewTasksEnvironment[
  label = (\arabic*\Star,
  ref = \theexercise.(\arabic*\Star ,
  label-format = \itshape,
  label-width = 15pt
]{follow}[\subquestionn](2)


\begin{document}

\begin{exercise}
  what is the name of the game? \label{game}
  \begin{parts}
    \subquestion who plays the game? \label{game1}
    \subquestion do they all lose? \label{game2}
   \end{parts}
\end{exercise}

\begin{exercise}
  what is the game? \label{name}
  \begin{follow}
    \subquestionn is it real? \label{name1}
    \subquestionn have you played it? \label{name2}
  \end{follow}
\end{exercise}

\section*{References}
Refer exercise cleverref = \cref{game} \\
Refer subquestion cleverref = \cref{game1} \\
Refer subquestion cleverref = \cref{game2}

Refer exercise cleverref = \cref{name} \\
Refer subquestion cleverref = \cref{name1} \\
Refer subquestion cleverref = \cref{name2}

\end{document}

在此处输入图片描述

相关内容