セクション内のパラリスト項目を参照する

セクション内のパラリスト項目を参照する

paralist私はサブセクションの代わりに's を使用していますasparaenum。ただし、場合によっては項目を参照したいこともありますasparaenum。以下は MWE です。

\documentclass[11pt]{book}
\usepackage{paralist}%
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\chapter{The First}\label{1-0}
\section{One}\label{1-1}
\begin{asparaenum}
\item%1
Some stuff
\item%2
Important Stuff
\end{asparaenum}
Occasionally, I would like to refer to just the item Important Stuff in \Cref{1-1} \nameref{1-1} rather than to the whole section 1.
\end{document}

答え1

アイテムの後にラベルを追加して\item\label{1-1-2}%2 Important Stuff、それを参照するなどしてください。\ref{1-1-2}

\verb+paralist+ パッケージの 6 ページからの抜粋:

ここに画像の説明を入力してください

あなたの例では:

\documentclass[11pt]{book}
\usepackage{geometry}

\usepackage{paralist}%
\usepackage{hyperref}
\usepackage{cleveref}

\usepackage{lipsum}
\begin{document}
\chapter{The First}\label{1-0}

Excerpt from \verb+paralist+ package, page 6:

\noindent\rule{\linewidth}{1pt}
As an example, we use \verb+asparaenum+ within this paragraph.
    \begin{enumerate}
\item   Every \verb+\item+ is basically set as a separate paragraph. The second
line is not indented (this is a feature, not a bug).
\item   The next \verb+\item+ looks like this and is labeled.
    \end{enumerate}
The example was produced by the following piece of code:
\begin{asparaenum}
\item Every \dots
\item The next \dots \label{pl1}
\end{asparaenum}
By saying \verb+\ref{pl1}+ we get \ref{pl1}.

The \verb+inparaenum+ environment formats an enumerated list within a paragraph, just like the one in the introduction.

The example in the introduction was set by the following commands:
\begin{verbatim}
\dots of an enumerated environment that
    \begin{inparaenum}[(a)]
    \item can be used within paragraphs,
    \item takes care of enumeration and
    \item has items that can be referenced. \label{pl2}
    \end{inparaenum}
Another posting mentioned ...
\end{verbatim}
By saying \verb+\ref{pl2}+ we get c.

\noindent\rule{\linewidth}{1pt}

\section{One}\label{1-1}
In your case:
    \begin{asparaenum}
\item   Some stuff
\item\label{item:1-1-2} Important Stuff
    \end{asparaenum}
Occasionally, I would like to refer to just the item \emph{Important Stuff}, e.g \cref{item:1-1-2} in above list \dots

\section{Two}\label{1-2}
With use referencing some list item, you should be aware that when you do again like in the following case:
    \begin{asparaenum}
\item   Some stuff second time
\item\label{item:1-2-2} Important Stuff again
    \end{asparaenum}
the  \emph{Important Stuff again} has the same \verb+\cref+ mark as before, but corect hyperlink, e.g \cref{item:1-2-2},

\lipsum[2]


\newpage\noindent
which work correctly  from any part of document, e.g see \cref{item:1-2-2} on the page \pageref{item:1-2-2}!

\lipsum[3]
\end{document}

ここに画像の説明を入力してください

答え2

ここに画像の説明を入力してください

プリアンブルに次のように入力します。

\crefname{aspar}{Important Item}{Important Items}
\Crefname{aspar}{Important Item}{Important Items}
\crefformat{aspar}{Important Item #1}
\newcommand{\labelasp}[1]{\label[aspar]{#1}} % a new command for custom referncing important items

は、パッケージを識別するasparための新しいラベル タイプです。は、重要な項目を識別するために使用できる新しいコマンドです。導入する名前は任意の名前に変更できますが、複数形と単数形を適切に設定するようにしてください。cleveref\labelaspImportant Item

完全なコードを以下に示します。

\documentclass[11pt]{report}
\usepackage{paralist}
\usepackage{hyperref}
\usepackage{cleveref}


\crefname{aspar}{Important Item}{Important Items}
\Crefname{aspar}{Important Item}{Important Items}
\crefformat{aspar}{Important Item #1}
\newcommand{\labelasp}[1]{\label[aspar]{#1}} % a new command for custom referncing important items


\begin{document}

\chapter{The First}\label{1-0}
\section{One}\label{1-1}


\begin{asparaenum}
\item Some stuff
\item \labelasp{imp1}
Important stuff 2
\item \labelasp{imp2}
Important stuff 3
\item \labelasp{imp3}
Important stuff 4


\end{asparaenum}


Now you can refer to \cref{imp1} in page \labelcpageref{imp1} or multiple \cref{imp2,,imp3,,imp1} in \cref{1-1}. 


\end{document}

関連情報