# insert \newcommand{*} in Glossary

I would like to add the output of

\newcommand{\ki}{\emph{K}\textsubscript{i}\mbox{ }}


in a Glossary entry. Is it possible?

As alternative, I would like to know which code I should use to define the same thing in Glossary.

Best, Davide

Here the minimal working example

\documentclass[a4paper,11pt,fleqn]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french,german,english]{babel}
\usepackage{listings}
\lstset{language=[LaTeX]Tex,tabsize=4, basicstyle=\scriptsize\ttfamily, showstringspaces=false, numbers=left, numberstyle=\tiny, numbersep=10pt, breaklines=true, breakautoindent=true, breakindent=10pt}

%\chapter*{List of abbreviations}
\markboth{List of abbreviations}{List of abbreviations}

\usepackage[toc,nopostdot,nonumberlist,nogroupskip]{glossaries}
\makenoidxglossaries

\newglossaryentry{ACN}{%
name={ACN},%
description={acetonitrile}%
}

\newglossaryentry{Ki}{%
name={??},%
description={??}%
}

\newcommand{\ki}{\emph{K}\textsubscript{i}\mbox{ }}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\printnoidxglossary[type=\acronymtype,title={List of abbreviations}]

This one works: \gls{ACN}

\end{document}


Edit:

1. what the \newcommand does is simply to print "ki" (inhibition constant, btw) with the proper formatting, so in this way I don't have to do it plenty of times in the text...I would be happy also to have it simply properly printed in the glossary, indeed I don't need any real connection to the text.
2. List item
3. \ki works in the file, the only problem I have is to have it in the glossary
4. I tried to change to \newcommand{\ki}{$K_i$} but the result is the same
5. here the error message

(c:/texlive/2014/texmf-dist/tex/latex/glossaries/styles/glossary-tree.sty Package: glossary-tree 2015/02/03 v4.13 (NLCT) \glstreeindent=\skip64 )) ! Undefined control sequence. \ki ->\emph {K}\textsubscript

Thanks again Davide

• Welcome to TeX.SX!! Rather than posting code fragments it is better to give a full minimal working example. Currently we have to guess what packages etc you are using and this makes it really hard to help you. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. This makes it much easier for people to help you --- and much more likely that they will! – Andrew Sep 14 '16 at 14:29
• What happened when you tried using it in a glossary entry? Perhaps it needs \protect\ki rather than simply \ki. – Nicola Talbot Sep 14 '16 at 14:45
• Dear Andrew, dear Nicola, thank you for the replies. I added the code. – user114166 Sep 14 '16 at 15:41

I'm not sure what your \ki command represents. (Should it be a variable in math-mode? What's the purpose of the trailing space?) However, from the macro point of view, the following compiles fine:

\documentclass[a4paper,11pt,fleqn]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french,german,english]{babel}

\usepackage[toc,nopostdot,nonumberlist,nogroupskip]{glossaries}

\makenoidxglossaries

\newglossaryentry{ACN}{%
name={ACN},%
description={acetonitrile}%
}

\newcommand{\ki}{\emph{K}\textsubscript{i}\mbox{ }}

\newglossaryentry{Ki}{%
name={\ki},%
sort={ki},
description={description of \ki}%
}

\begin{document}

\printnoidxglossary[type=\acronymtype,title={List of abbreviations}]

This one works: \gls{ACN}

\gls{Ki}.

\end{document}


This produces:

Edit: I don't know why you're getting an undefined control sequence relating to \ki. Things to check:

• Did you copy and paste the MWE exactly? (Is there a case slip, such as \Ki instead of \ki?)
• Does \ki work on its own in the document? It may be that \textsubscript is the undefined control sequence, which would mean you have an old version of the LaTeX kernel. (This is unrelated to your WinEdt version.) What happens if you change the definition of \ki to

\newcommand{\ki}{$K_i$}


Do you still get an error?

• Add \listfiles to the MWE and rerun. Then copy and paste the exact error message and the file list from the transcript (.log file) into your question.

• Hello Nicola, thank you for the kind reply. I don't know what we do differently but with me your code doesn't work. I get the error "undefined control sequence" for "\ki -->\emph{K}etcetc". I use WinEdt 10.1 if this can help – user114166 Sep 15 '16 at 8:02

I partially solved the problem in this way:

\newglossaryentry{Ki}{%
name={\ensuremath{K_{\mathrm{i}}}},%
description={acetonitrile}%
}


I came across two other issues:

1. Ki is not printed in bold in the glossary
2. never mind where I place it, it always appears at the top of the lis

solutions? Thanks

• I think it would be better to move this to your question, as it's not a complete answer. – Nicola Talbot Sep 26 '16 at 17:13