forum icon indicating copy to clipboard operation
forum copied to clipboard

使用 xeCJK 时,如何定义 cleveref 的格式?

Open gaochenyi opened this issue 3 years ago • 1 comments

检查

  • [x] 已在 issues 中进行搜索(包括已关闭的问题)

描述问题

如题,我自己的尝试总是不能正确处理好空格。 目标是让宏 \cref 在使用时可当作英文短语,但其中包含中文时也能正确处理好空格。

https://github.com/CTeX-org/ctex-kit/issues/491 提到的技术可以用在这里吗?

最小工作示例(MWE)

\documentclass{ctexart}\pagestyle{plain}
\RequirePackage{xeCJK}% with XeTeX

\usepackage[a6paper,hmargin=0.5cm,vmargin=.5cm]{geometry}

\usepackage{cleveref}
\newcommand{\crefrangeconjunction}{至}
\newcommand{\crefpairconjunction}{和}
\crefname{section}{}{}  \creflabelformat{section}{#2#1#3~节}
\crefname{figure}{图}{图}% This could not handle the space token in front of `\cref`.
% \crefname{figure}{\unskip 图}{\unskip 图}% Space tokens are always removed. This is not the expected behaviour.

\begin{document}

\subsection{对照组}
,word,\par
, word ,\par
字word字\par
字 word 字\par

\subsection{测试组}
\subsubsection{figure}
0\quad ,\cref{fig:A},\par
1\quad , \cref{fig:A} ,\par
2\quad 字\cref{fig:A} 字\par
3\quad 字 \cref{fig:A} 字\par
\subsubsection{section}
4\quad ,\cref{sec:a},\par
5\quad , \cref{sec:a} ,\par
6\quad 字\cref{sec:a} 字\par
7\quad 字 \cref{sec:a} 字\par
\subsubsection{mix}
8\quad \cref{sec:a,sec:b,sec:c,fig:C}\par
9\quad \cref{fig:A,fig:B,fig:C,sec:c}\par

\subsection{准备}
\subsubsection{a}\label{sec:a}
\subsubsection{b}\label{sec:b}
\subsubsection{c}\label{sec:c}
\subsubsection{d}\label{sec:d}
\subsubsection{e}\label{sec:e}
\subsubsection{f}\label{sec:f}

\begin{figure}[htbp]
\parbox{.15\linewidth}{\centering\Large A\caption{\label{fig:A}}}
\parbox{.15\linewidth}{\centering\Large B\caption{\label{fig:B}}}
\parbox{.15\linewidth}{\centering\Large C\caption{\label{fig:C}}}
\parbox{.15\linewidth}{\centering\Large D\caption{\label{fig:D}}}
\parbox{.15\linewidth}{\centering\Large E\caption{\label{fig:E}}}
\parbox{.15\linewidth}{\centering\Large F\caption{\label{fig:F}}}
\end{figure}

\end{document}

用 XeLaTeX 编译后输出

Screenshot 2021-05-12 at 20 20 30

gaochenyi avatar May 12 '21 12:05 gaochenyi

我也有相同的问题, 感觉目前只能手动调节空格

MrGodfrey avatar Jan 14 '23 02:01 MrGodfrey