TLDR; I'd like an index (like) command that fully expands before executing, so that \newcommand{\words}{Some important Words}\indexCMD{\words}

is exactly like \indexCMD{Some important Words} - as if \words has fully expanded before \index does anything

Plain LaTeX, please.

I have a serious problem, which I can't get my head around how to fix:

I'd like to use splitidx to create several indexes at the end of my Bachelor's thesis, however, in order to consolidate and automate some part of the indexing I'm writing a macro, that automatically adds something to the appropriate index if I use an equivalent of \gls (glossaries-extra) or \ac (acro). My problem is, that every index entry shall have capitalised words, since I'm mixing German and English, and be correctly sorted. I'd like to have a command that makes \index{some Words here AND there} equivalent to \index{Some Words Here AND There}





    \inindex{Words are} not as important as other \inindex{words are}.

\newcommand{\inindex}[1]{#1\sindex[stw]{#1@\protect\capitalisewords{#1}}} is working only superficially since they are sorted how they are called so "some Words here AND there" gets a different entry from "Some Words Here AND There} and they appear twice but identically. I only know LaTeX and only little TeX and would like an answer I can fully understand (by explaining each step) and learn from. I tried \expandafter, \expanded and \noexpand in all shapes but never successfully.

Identical problem, different scenario:

\Acl and \Acs are from the acro package

    short = CFD,
    long = numerische Strömungsmechanik
        id = {#1},
        description = {#2},
        longName = \Acl{#1},
        shortName = \Acs{#1}

How do I need to modify this, in order for it to be equivalent to

        id = {cfd} ,
        description = {Beschreibung},
        longName = Numerische Strömungsmechanik,
        shortName = CFD
  • Welcome! I'm afraid that it's not possible: \Acl is not expandable and just prints the acronym. Do you need two separate commands? Wouldn't it be easier to use just the \newglossaryentryac command, with more keys to perform also the \DeclareAcronym command?
    – egreg
    Jun 18, 2020 at 20:04
  • I've tried and tried but either biblatex breaks, it is not compilable, or whatnot. I've tried , using the keycommand package, to define everything separately but due to umlauts (äüö) or \cite it just won't work. It seems I need to do everything manually.
    – learex
    Jun 18, 2020 at 20:31

1 Answer 1


My proposal is to define a single command that does both the \DeclareAcronym and the \newglossaryentry business.



\keys_define:nn { learex/glossac }
  short .tl_set:N = \l__clearex_glossac_short_tl,
  long  .tl_set:N = \l__clearex_glossac_long_tl,
\tl_new:N \l__clearex_glossac_Short_tl
\tl_new:N \l__clearex_glossac_Long_tl

 {% #1 = key, #2 = options, #3 = description
  \keys_set:nn { learex/glossac }
   {% clear all keys
    % assign the values
  \tl_set:Nx \l__clearex_glossac_Short_tl
    \text_titlecase_first:V \l__clearex_glossac_short_tl
  \tl_set:Nx \l__clearex_glossac_Long_tl
    \text_titlecase_first:V \l__clearex_glossac_long_tl
    % acro
      short = \text_expand:n {\l__clearex_glossac_short_tl},
      long = \text_expand:n {\l__clearex_glossac_long_tl},
    % glossaries
    \exp_not:N \newglossaryentry {#1}
      name = \text_expand:n {\l__clearex_glossac_Long_tl},
      \exp_not:n { description = #3\glslink{#1s} },
    \exp_not:N \newglossaryentry{#1s}
      name = \text_expand:n {\l__clearex_glossac_Short_tl},
      \exp_not:n { description = {siehe~\gls{#1}} },
\cs_generate_variant:Nn \text_titlecase_first:n { V }


    short = CFD,
    long = numerische Strömungsmechanik

    short = TST,
    long = test
    short = übr,
    long = über


\Acl{cfd} \Acl{cfd} \acl{cfd} \Acs{cfd} \acs{cfd}

\gls{cfd} \gls{cfds}

\Acl{tst} \Acs{tst}

\gls{tst} \gls{tsts}

\Acl{ubr} \Acs{ubr} \acl{ubr} \acs{ubr}

\gls{ubr} \gls{ubrs}



Uppercasing the initial is obtained by using \text_titlecase_first:n. The \use:x part is because we want the value of the variables, not the variables. With \text_expand:n we are sure that special characters are not mangled.

enter image description here

  • I was able to get it to work, I'll only need to expand it to cope with the occasionally appearing foreign form
    – learex
    Jun 18, 2020 at 21:32
  • What would be a good resource to learn the syntax you used in your answer? I’m very unfamiliar with it.
    – learex
    Jun 18, 2020 at 22:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .