내 질문은이 하나.
package 를 사용하면 cleveref
레이블이 지정된 여러 개체를 동시에 참조할 때 multiformat 명령을 사용하여 \cref
예를 들어 다음과 같은 결과를 얻을 수 있습니다.참조 1, 2 및 3또는 범위 형식 명령을 사용하여 \crefrange
결과를 얻습니다.참조 1–3.
레이블이 지정된 개체가 1a, 1b, 1c인 경우 범위 형식을 조정하여 \crefstripprefix
공통 접두사를 제거할 수 있습니다.
\crefrangelabelformat{<type>}{#3#1#4--#5\crefstripprefix{#1}{#2}#6}
굽힐 수 있는참조 1a–c대신에참조 1a–1c.
나는 다중 형식과 비슷한 것을 달성하고 싶습니다.참조 1a, b, c. 불행하게도 #1
범위의 첫 번째 레이블을 나타내고 #2
마지막 레이블을 나타내는 위와 달리 \creflabelformat
명령은 레이블을 개별적으로 구성합니다(자리 표시자만 #1
사용할 수 있으며 #2
위와 같이 #3
하이퍼링크를 조정합니다 ).#3
#6
\cref
with a series of label 의 출력은 \crefmultiformat
명령에 의해 조정됩니다. 여기서 인수에 나타나는 자리 표시자는 #1
계열의 각 레이블을 한 번에 하나씩 나타냅니다. 각 레이블을 먼저 "명령으로 조정하여 변형을 거치게 하는 방법이 있습니까?"\crefmultilabelformat
각 레이블을 먼저 변환하고 " "둘자리 표시자는 #1
시리즈의 첫 번째 렌더링된 레이블을 나타내고 #2
나머지 레이블은 어디를 나타냅니까?
\documentclass{article}
\usepackage{floatrow}
\usepackage{subcaption}
\usepackage{cleveref}
\crefrangelabelformat{figure}{#3#1#4--#5\crefstripprefix{#1}{#2}#6}
\begin{document}
\begin{figure}
\ffigbox[\textwidth]{
\begin{subfloatrow}[3]
\ffigbox[\FBwidth]{\quad a \quad}{\caption{a}\label{sfig:a}}
\ffigbox[\FBwidth]{\quad b \quad}{\caption{b}\label{sfig:b}}
\ffigbox[\FBwidth]{\quad c \quad}{\caption{c}\label{sfig:c}}
\ffigbox[\FBwidth]{\quad d \quad}{\caption{d}\label{sfig:d}}
\end{subfloatrow}
}{\caption{cap}\label{fig:1}}
\end{figure}
%
\crefrange{sfig:a}{sfig:c} % renders 1a-c, juste like I want
\cref{sfig:a,sfig:b,sfig:d} % renders 1a, 1b and 1d, and I would like 1a, b, and d.
\end{document}
답변1
\crefmultiformat
이 작업에는 새 명령이 필요하지 않으며 다음과 같이 매크로를 사용하여 첫 번째 구성 요소의 접두사 정보를 다른 구성 요소에 전달함으로써 기존 명령으로 수행할 수 있습니다 .
\documentclass{article}
\usepackage{floatrow}
\usepackage{subcaption}
\usepackage{cleveref}
\crefrangelabelformat{figure}{#3#1#4--#5\crefstripprefix{#1}{#2}#6}
\crefmultiformat{figure}%
{\edef\mycrefprefixinfo{#1}figs.~#2#1#3}%
{ and~#2\crefstripprefix{\mycrefprefixinfo}{#1}#3}%
{, #2\crefstripprefix{\mycrefprefixinfo}{#1}#3}%
{, and~#2\crefstripprefix{\mycrefprefixinfo}{#1}#3}
\begin{document}
\begin{figure}
\ffigbox[\textwidth]{
\begin{subfloatrow}[3]
\ffigbox[\FBwidth]{\quad a \quad}{\caption{a}\label{sfig:a}}
\ffigbox[\FBwidth]{\quad b \quad}{\caption{b}\label{sfig:b}}
\ffigbox[\FBwidth]{\quad c \quad}{\caption{c}\label{sfig:c}}
\ffigbox[\FBwidth]{\quad d \quad}{\caption{d}\label{sfig:d}}
\end{subfloatrow}
}{\caption{cap}\label{fig:1}}
\end{figure}
\crefrange{sfig:a}{sfig:c} % renders "1a-c", just like I want.
\cref{sfig:a,sfig:b,sfig:d} % renders "1a, b, and d", just like you want.
\end{document}