如何列出部分小节

如何列出部分小节

现在我有一份已标记的问题清单。

\documentclass[10pt]{article}
\usepackage[hidelinks]{hyperref}
\usepackage{enumitem}

\begin{document}

    \newpage
    \section{Project}
    This is a researsch report.

    \subsection{Objective}
    Blablabla.

    \noindent\newline
    \large\textit{"Is this the main question?"}

    \noindent\newline
    sub questions:

    \begin{enumerate}[label=\textit{Q \roman*}, ref=\textit{Question \roman*}]
      \item \label{q1} {\normalsize\textit{"What is this question?"}}
      \item \label{q2} {\normalsize\textit{"Why is this a question?"}}
      \item \label{q3} {\normalsize\textit{"How is this a question?"}}
    \end{enumerate}
    \noindent

    \section{Research}
    Blablabla.

    \subsection{\ref{q1}: What is this question?}
    Blablabla.

    \subsection{\ref{q2}: Why is this a question?}
    Blablabla.

    \subsection{\ref{q3}: How is this a question?}
    Blablabla.

\end{document}

其结果是:

在此处输入图片描述

例子: 在背面。

问题在于,子节标题链接到列表,如果反过来会更容易理解。因此,我给标题贴上标签,并在标题中添加替代计数,然后根据此生成列表。

这个怎么做?

答案1

您可以使用新的计数器和来实现这一点\refstepcounter

\documentclass[10pt]{article}
\usepackage[hidelinks]{hyperref}
\usepackage{enumitem}

% New counter for questions
\newcounter{question}
% Questions are labelled using lower case roman numerals
\renewcommand\thequestion{\roman{question}}

\begin{document}

    \newpage
    \section{Project}
    This is a researsch report.

    \subsection{Objective}
    Blablabla.

    \noindent\newline
    \large\textit{"Is this the main question?"}

    \noindent\newline
    sub questions:

    \begin{itemize}
      \item[Q \ref{what}]  {\normalsize\textit{"What is this question?"}}
      \item[Q \ref{why}]  {\normalsize\textit{"Why is this a question?"}}
      \item[Q \ref{how}]  {\normalsize\textit{"How is this a question?"}}
    \end{itemize}
    \noindent

    \section{Research}
    Blablabla.

    % Increment the question counter while also setting \ref to its value
    \refstepcounter{question}
    % Set "what" to \ref, which is the counter's value
    \label{what}
    % Use the counter's value for the subsection title
    \subsection{Question \thequestion: What is this question?}
    Blablabla.

    \refstepcounter{question}
    \label{why}
    \subsection{Question \thequestion: Why is this a question?}
    Blablabla.

    \refstepcounter{question}
    \label{how}
    \subsection{Question \thequestion: How is this a question?}
    Blablabla.

\end{document}

我不会为回答问题的每个小节重复这三行,而是创建一个新命令:

\newcommand\qsubsection[2]{
  \refstepcounter{question}
  \label{#1}
  \subsection{Question \thequestion: #2}
}

然后写下,例如,

 \qsubsection{what}{What is this question?}
    Blablabla.

相关内容