cgnieder / acro

acronyms for LaTeX
LaTeX Project Public License v1.3c
41 stars 9 forks source link

How to activate `\acspace`? #239

Closed DaftDogeee closed 2 years ago

DaftDogeee commented 2 years ago

Hi, Clemens,

The manual says that \acspace inserts a \space if no dash or babel-hyphen follows.

However, I make the following try, and \acspace is not still activated.

May I have a wrong understanding for that?

A\acspace-B

A-\acspace{}B

cgnieder commented 2 years ago

\acspace works inside of an acronym template or acronym definition. It depends on the setting of trailing/activate and only has an effect if dash has been activated:

\documentclass{article}
\usepackage{acro}

% \NewAcroTemplate{long-short}{%
%   \acroiffirstTF{%
%     \acrowrite{long}%
%     \acspace(% <<<<<<< HERE
%       \acroifT{foreign}{\acrowrite{foreign}, }%
%       \acrowrite{short}%
%       \acroifT{alt}{ \acrotranslate{or} \acrowrite{alt}}%
%       \acrogroupcite
%     )%
%   }%
%   {\acrowrite{short}}%
% }

% example from the manual
\DeclareAcronym{PU}{
  short = PU ,
  long = Polyurethan ,
  long-plural = e
}

\DeclareAcronym{AB}{
  short = A\acspace B ,
  long = aaa\acspace bbb ,
}

\acsetup{trailing/activate = dash}

\begin{document}

\paragraph{No Space}
\ac{PU}-Hartschaum \ac{AB}-test

\acresetall

\paragraph{Space}
\ac{PU} \ac{AB}

\end{document}

image

DaftDogeee commented 2 years ago

Thanks for reply.

Based on your example, I make another try, and the example is listed as follow. I just wonder that why the comma is not activated.

\documentclass{article}
\usepackage{acro}

\DeclareAcronym{PU}{
  short = PU ,
  long = Polyurethan ,
  long-plural = e
}

\DeclareAcronym{AB}{
  short = A\acspace B ,
  long = aaa\acspace bbb ,
}

\acsetup{trailing/activate = {comma,dash}}

\begin{document}

\paragraph{No Space}
\ac{PU}-Hartschaum \ac{AB},test

\acresetall

\ac{PU}-Hartschaum \ac{AB}-test

\acresetall

\paragraph{Space}
\ac{PU} \ac{AB}

\end{document}

截屏2022-03-16 下午1 11 36

cgnieder commented 2 years ago

Well, as I wrote it only reacts to dash (and babel-hyphen). That is, because I only know “real-life” examples (and only German ones, to be honest) in combination with a dash. But you can redefine \acro_space: to react on comma as well:

\cs_set:Npn \acro_space:
  { \acro_trailing_if_tokens:nF {dash,babel-hyphen,comma} { \c_space_tl } }
DaftDogeee commented 2 years ago

Many thanks.

I think now I completely understand how does \acspace work.

The reason why I attempt to patch \acspace is that I am working on the adaptation of acro for Chinese. But, I think the core issue may exist in the ctex. It may involve the joint typesetting problem of Chinese and English, such as #491.