我如何减少参考文献以仅显示小节编号?

我如何减少参考文献以仅显示小节编号?

我使用cleveref包来格式化特殊类型的标签。我也可以在其中使用特殊计数器或计数器格式化序列吗?\cref这是我的示例:

\documentclass[10pt,a4paper,twoside]{article}
\usepackage{chngcntr}
\usepackage{cleveref}
\usepackage{assoccnt}
\makeatletter
  \crefname{ap}{package}{packages}
  \Crefname{ap}{Package}{Packages}
  \creflabelformat{ap}{AP~#2#1#3}
  \crefformat{ap}{AP~#2#1#3}
\makeatother

\begin{document}

  \newcounter{ap}{}
  \DeclareAssociatedCounters{subsection}{ap}
  \counterwithout{ap}{section}

  \section{ some section  }
  \section{ special section on packages  }
  \setcounter{ap}{0}

      Here we describe \cref{sec:ap-one,sec:ap-two,sec:ap-three}  ....
      this will be presented in \cref{sec:ap-one,sec:ap-two} and 
      finally in \cref{sec:ap-three}we describe ....

    Preferably this should look like this:

      Here we describe package AP 1 to AP 3  .... 
      this will be presented in packages AP 1 and AP 2 and 
      finally in package AP 3 we describe ....

    but currently it looks like this:

      Here we describe package AP 2.1 to AP 2.3  .... 
      this will be presented in packages AP 2.1 and AP 2.2 and 
      finally in package AP 2.3 we describe ....

   \subsection{AP~\arabic{ap}: first }
   \label[ap]{sec:ap-one}
     bla bla bla
     Here we describe  ... 
     which will be used in \cref{sec:ap-two,sec:ap-three}  ....

   \subsection{AP~\arabic{ap}: second }
   \label[ap]{sec:ap-two}
     bla bla bla
     we described in \cref{sec:ap-one}  .... 
     follow in \cref{sec:ap-three}

     ap counter is \arabic{ap} or \theap.

     subsection counter is \arabic{subsection} 
     and ``thesection'' is \thesubsection.


   \subsection{AP~\arabic{ap}: three }
   \label[ap]{sec:ap-three}
     bla bla bla
     we described in \cref{sec:ap-one,sec:ap-two}  


  \section*{Appendix}
     The table of contents is fine as is 
  \tableofcontents

\end{document}

答案1

更新:从 1.2 版开始,xassoccnt支持将标签添加到关联计数器的实验性功能。请参阅下面 1.2 版(及更高版本)的示例

在一些“错误”的等等的使用\newcounter以及应该是最后一个被包含的包的事实cleveref中,使用错误输出的主要原因在于假设\label[ap]{...}计数器ap已经与一起使用\refstepcounter,但事实并非如此。

我设计了该assoccnt包(及其后继者xassoccnt),使其具有关联计数器,当主计数器步进时,关联计数器也会步进(subsection此处),但拒绝也应用此功能\refstepcounter,因为这会产生歧义——关联计数器将步进,但每个计数器都会设置条目\@currentlabel,从而覆盖主计数器label。由于关联计数器的值与其主计数器完全不同,因此该\label命令会将错误的计数器和参考值写入.aux文件。

现在,\refstepcounter将使用子部分值,并且这仍然是格式2.1,因此\label[ap]{...}写入一些{2.1}值作为对.aux文件的引用。

解决方案是使用不同的标签命令,它会生成\@currentlabel适合的假标签cref然后设置值。

\documentclass[10pt,a4paper,twoside]{article}
\usepackage{chngcntr}
\usepackage{xassoccnt}

\newcounter{ap}
\DeclareAssociatedCounters{subsection}{ap}
\counterwithout{ap}{section}

\usepackage{cleveref}
\makeatletter
% Generate a fake label
\newcommand{\labelap}[2][ap]{%
  \def\@tempa{#1}%
  \def\cref@result{2}%
  \protected@edef\cref@currentlabel{%
    [\@tempa][\arabic{#1}][\cref@result]%
    \csname p@#1\endcsname\csname the#1\endcsname}%
  \label[ap]{#2}%
}
\makeatother

\crefname{ap}{package}{packages}
\Crefname{ap}{Package}{Packages}
\creflabelformat{ap}{AP~#2#1#3}
\crefformat{ap}{AP~#2#1#3}

\begin{document}


  \section{ some section  }
  \section{ special section on packages  }
  \setcounter{ap}{0}

      Here we describe \cref{sec:ap-one,sec:ap-two,sec:ap-three}  ....
      this will be presented in \cref{sec:ap-one,sec:ap-two} and 
      finally in \cref{sec:ap-three}we describe ....

    Preferably this should look like this:

      Here we describe package AP 1 to AP 3  .... 
      this will be presented in packages AP 1 and AP 2 and 
      finally in package AP 3 we describe ....

    but currently it looks like this:

      Here we describe package AP 2.1 to AP 2.3  .... 
      this will be presented in packages AP 2.1 and AP 2.2 and 
      finally in package AP 2.3 we describe ....

   \subsection{AP~\arabic{ap}: first }
   \labelap{sec:ap-one}
     bla bla bla
     Here we describe  ... 
     which will be used in \cref{sec:ap-two,sec:ap-three}  ....

   \subsection{AP~\arabic{ap}: second }
   \labelap{sec:ap-two}
     bla bla bla
     we described in \cref{sec:ap-one}  .... 
     follow in \cref{sec:ap-three}

     ap counter is \arabic{ap} or \theap.

     subsection counter is \arabic{subsection} 
     and ``thesection'' is \thesubsection.


   \subsection{AP~\arabic{ap}: three }
   \labelap{sec:ap-three}
     bla bla bla
     we described in \cref{sec:ap-one,sec:ap-two}  


  \section*{Appendix}
     The table of contents is fine as is 
  \tableofcontents

\end{document}

1.2 版解决方案风格

\documentclass[10pt,a4paper,twoside]{article}
\usepackage{chngcntr}
\usepackage{xassoccnt}
\usepackage{hyperref}
\NewDocumentCounter{ap, apother}
\DeclareAssociatedCounters{subsection}{ap, apother}

\counterwithout{ap}{section}

\usepackage{cleveref}

\crefname{ap}{package}{packages}
\Crefname{ap}{Package}{Packages}
\creflabelformat{ap}{AP~#2#1#3}
\crefformat{ap}{AP~#2#1#3}

\begin{document}

See \cref{foosection}

  \section{ some section  } \label{foosection}
  \section{ special section on packages  }
  \setcounter{ap}{0}

      Here we describe \cref{ap::ap-one,ap::ap-two,ap::ap-three}  ....
      this will be presented in \cref{ap::ap-one,ap::ap-two} and 
      finally in \cref{ap::ap-three} we describe ....

    Preferably this should look like this:

      Here we describe package AP 1 to AP 3  .... 
      this will be presented in packages AP 1 and AP 2 and 
      finally in package AP 3 we describe ....

    but currently it looks like this:

      Here we describe package AP 2.1 to AP 2.3  .... 
      this will be presented in packages AP 2.1 and AP 2.2 and 
      finally in package AP 2.3 we describe ....

   \subsection{AP~\arabic{ap}: first } \label{ap-one}
     bla bla bla
     Here we describe  ... 
     which will be used in \cref{ap::ap-two,ap::ap-three}  ....


   \subsection{AP~\arabic{ap}: second }
   \label{ap-two}
     bla bla bla
     we described in \cref{ap::ap-one}  .... 
     follow in \cref{ap::ap-three}

     ap counter is \arabic{ap} or \theap.

     subsection counter is \arabic{subsection} 
     and ``thesection'' is \thesubsection.


   \subsection{AP~\arabic{ap}: three }
   \label{ap-three}
     bla bla bla
     we described in \cref{ap::ap-three,ap::ap-two} but look at \ref{ap-three}  


  \section*{Appendix}
     The table of contents is fine as is 
  \tableofcontents

\end{document}

相关内容