I use the ampersand in the body of my these when I need to say "and"… often, you can imagine! After open my document, I use:
makeampletter
\def\makeampletter{\catcode`\&11\relax}
If I need to put a table, I turn:
makeampcolsep
\def\makeampcolsep{\catcode`\&4\relax}
That's my way, because I don't know how to transform my "and", or my "et" in french, in "&" (historically, "&" is the ligature of "et"). Furthermore, if I transform all "and" or "et" in "&", I'll turn all "Brandies" in "Br&ies" and all "Cabernet" in "Cabern&", perplexing. &, I don't want to start my sentences with "&". There could be a solution: transform as a ligature only if the conjunction is between spaces or punctuation « et » or " and " or « -et- », and if the world is in lower case... If you can build this solution, I'll take it. So, I write with "&" in my text. Sometimes, I know, it's a bad idea, in tables, in titles, in labels etc. I bypass. But, I need to use "&" in glossaries descriptions. I show in the MWE a little program who explain why \&
, \&\
, or {\&}
are not good solutions for me (space management, correspondence with other functions).
Here is my question: to freely use the ampersand, how to automatise the use of &
sign in all descriptions of glossary entries ? Use my friendly programs makeampletter
& makeampcolsep
, but where ?
% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = arara
\documentclass{scrbook}
\def\makeampletter{\catcode`\&11\relax}
\newcommand\ampersandtrip[2]{\newglossaryentry{#1}{name=#1,type=main,description={#2}}#2\footnote{\gls{#1}}}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{and}{name=and,description={I want to use my &!}}% \&
\newglossaryentry{et}{name=et,description={Je veux utiliser mon & !}}% \&
\begin{document}
\makeampletter
\gls{and} & \gls{et}
\section*{Trip 1}\glsentrydesc{trip1}\\\ampersandtrip{trip1}{You \& me}
\section*{Trip 2}\glsentrydesc{trip2}\\\ampersandtrip{trip2}{Toi \& moi}
\section*{Trip 3}\glsentrydesc{trip3}\\\ampersandtrip{trip3}{You \&\ me}
\section*{Trip 4}\glsentrydesc{trip4}\\\ampersandtrip{trip4}{Toi {\&} moi}
\printglossary
\end{document}
% arara: xelatex
% arara: makeglossaries
% arara: xelatex
It sounds silly, but I need it. Thanks!
\&
than to try to make it temporarily into an ordinary character. since that is a non-letter "control symbol", it won't gobble the space that follows in the input, so if you want a space there, you can input it without doing anything special. – barbara beeton Jun 27 '16 at 20:26\glsentrydesc
. So, through these trips, spaces politic after\&
are different. Ok, I edit my post for explain this necessity. – Zouib Jun 27 '16 at 22:11\begin{document}
when the.glsdefs
file is read in, so the change in catcode comes too late for those entries. – Nicola Talbot Jun 27 '16 at 22:48