TeX - LaTeX Asked by Eli4ph on January 8, 2021
I would like to make cref
after expansion stand at the same group of surrounding text.
With crefname{figure}{图}{图}
, I need to use 如cref{...} 所示
to make typesetting correct, if the counter of figure
environment is not set to Chinese numbers.
Note that there is no whitespace before cref
whereas there is one after.
This make cref{...}
bear no resemblance to Chinese or English.
Therefore the syntax becomes more complex—there are three languages: Chinese, English, a virtual language starting with Chinese but ending with English.
Besides, the virtual language is dependent on the format of counter.
By making the expansion of cref
stand at the same group of surrounding text, the third one is eliminated, and there is neither behavioral nor syntactic change in English-only scenario, since cref
is semantically treated like an ordinary English word in the text and always surrounded by spaces.
Bearing in mind that grouping is desired sometimes (e.g., when one uses crefname{figure}{bfseries FIG.}{bfseries Fig.}
), I prefer (if possible) a switch.
I guess this request is much like making the expansion of textbf{...}
stand at the same group of surrounding text.
Could this be achieved?
EDIT: With XeLaTeX, the following code gives the output:
MWE:
% !TEX program = xelatex
documentclass{article}
usepackage{ctex}% Note: some Chinese fonts are needed
usepackage[a6paper]{geometry}
usepackage{cleveref}
crefname{figure}{图}{图}
begin{document}
begin{figure}
centering
$a^2 + b^2 = c^2$
caption{test}
label{eq:test}
end{figure}
中文 字符 之间 不 需要 空格。% direct translation of each piece: Chinese, character(s), between, not, need, whitespace(s). Combination: There is no need to place whitespaces between Chinese characters.
前后par % case 1
前 后par% case 2
前cref{eq:test}后 --- verb|cref|par % case 3
前 cref{eq:test} 后 --- verb|cref|par% case 4. I would like to make case 4 behave like case 3.
前ref{eq:test}后 --- verb|ref|par % case 5
前 ref{eq:test} 后 --- verb|ref|par% case 6. I would like to make case 6 behave like case 5.
Note the very different behaviour of verb|ref| and verb|cref|.
one textbf{two} threepar
onetextbf{two}threepar
end{document}
You can suppress the space by redefining the format commands. If you want it also for normal ref, the easiest is to define your own command:
documentclass{article}
usepackage{ctex}% Note: some Chinese fonts are needed
usepackage[a6paper]{geometry}
usepackage{cleveref}
crefname{figure}{unskip 图}{unskip 图}
crefdefaultlabelformat{#2#1#3aftergroupignorespaces}
newcommandmyref[1]{unskipref{#1}ignorespaces}
begin{document}
begin{figure}
centering
$a^2 + b^2 = c^2$
caption{test}
label{eq:test}
end{figure}
前后par % case 1
前 后par% case 2
前cref{eq:test}后 --- verb|cref|par % case 3
前 cref{eq:test} 后 --- verb|cref|par% case 4. I would like to make case 4 behave like case 3.
前myref{eq:test}后 --- verb|ref|par % case 5
前 myref{eq:test} 后 --- verb|ref|par% case 6. I would like to make case 6 behave like case 5.
Note the very different behaviour of verb|ref| and verb|cref|.
end{document}
Answered by Ulrike Fischer on January 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP