Creating a macro from a parameter where the first letter has to be capitalized turns out to be extremely difficult (or I am doing something wrong). It comes down to the fact that \uppercase
is not expandable. And \uppercase{\csname #1\endcsname}
would capitalize the entire word...
The easiest thing that I can think of is to give the uppercase word as a parameter as well. That is, you could use the following:
\documentclass[12pt]{article}
\def\mynewglos#1#2#3{%
\newglossaryentry{#1}{#3}%
\expandafter\def\csname #1\endcsname{\gls{#1}}%
\expandafter\def\csname #2\endcsname{\Gls{#1}}%
}
\usepackage{glossaries}
\makeglossaries{}
\begin{document}
\mynewglos{electrolyte}{Electrolyte}{name=electrolyte,description={solution able to conduct electric current}}
\gls{electrolyte} or \electrolyte{} or \Gls{electrolyte} or \Electrolyte
\printglossaries
\end{document}
Note that this defines \Abbr
as the capitalized version \Gls
instead of the regular version. You can simply change that in the definition containing #2
. If it is not required, you can also remove the lowercase definitions by removing the definition containing #1
.
If someone has a good way to define \Abbr
from a macro where only abbr
is passed as an argument, I would very much like to see it :)
newglossaryentry
macro in something that defines two new macros (upper and lowercase) and then does the originalnewglossaryentry
?