4

I'm wondering how to make just specific entries in a glossary package acronym list appear in small caps. I found other threads where someone has asked how to make all entries small caps but not how to make just one specific entry in small caps. I've tried doing the following:

\documentclass[12pt,a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[acronym,sort=use,toc,nopostdot]{glossaries}

\newacronym{ac}{ac}{Alternating Current}
\newacronym{mosfet}{{\sc mosfet}}{Metal Oxide Semiconductor Field Effect Transistor}

\makeglossaries

\begin{document}

\printglossary[type=\acronymtype,title=Abbreviations]

\gls{mosfet} is supposed to be written in small caps but \gls{ac} is not.

\end{document}

The problem I get with this is that all other entries are bold while that particular one in small caps is not in bold. So the abbreviations list looks quite ugly. Does anyone here know an easy fix for this problem?

2

The command \sc is obsolete; it will not only switch to small caps, but switch off other font features like bold. Use \scshape instead. (Alternatively, you may use \textsc{<text in small caps>} and do away with the additional group.)

  • Thanks for the help! I thought that \sc was the only "text altering command" that wasn't obsolete. So thanks for the heads up. It worked wonders using \scshape instead! – ekmanch Feb 12 '14 at 10:28
3

You need at least version 4.02 for the following:

\documentclass[12pt,a4paper]{report}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[acronym,sort=use,toc,nopostdot]{glossaries}

\glssetnoexpandfield{useri}

\newacronymstyle{long-alt-short}
{%
  \ifdefempty\glscustomtext
  {%
    \ifglsused\glslabel
    {%
      \glsifplural
      {%
        \glscapscase
        {%
          {\glsentryuseri{\glslabel}\glsentryshortpl{\glslabel}}\glsinsert
        }%
        {%
          {\glsentryuseri{\glslabel}\Glsentryshortpl{\glslabel}}\glsinsert
        }%
        {%
          \mfirstucMakeUppercase
            {{\glsentryuseri{\glslabel}\glsentryshortpl{\glslabel}}\glsinsert}%
        }%
      }%
      {%
        \glscapscase
        {%
          {\glsentryuseri{\glslabel}\glsentryshort{\glslabel}}\glsinsert
        }%
        {%
          {\glsentryuseri{\glslabel}\Glsentryshort{\glslabel}}\glsinsert
        }%
        {%
          \mfirstucMakeUppercase
            {{\glsentryuseri{\glslabel}\glsentryshort{\glslabel}}\glsinsert}%
        }%
      }%
    }%
    {%
      \glsifplural
      {%
        \glscapscase
        {%
          \genplacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
          \Genplacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
          \mfirstucMakeUppercase
            {\genplacrfullformat{\glslabel}{\glsinsert}}%
        }%
      }%
      {%
        \glscapscase
        {%
          \genacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
          \Genacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
          \mfirstucMakeUppercase
           {\genacrfullformat{\glslabel}{\glsinsert}}%
        }%
      }%
    }%
  }%
  {%
    \glscustomtext
  }%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\acrpluralsuffix}{\glstextup{\glspluralsuffix}}%
  \renewcommand*{\genacrfullformat}[2]{%
   \glsentrylong{##1}##2\space
   ({\glsentryuseri{##1}\glsentryshort{##1}})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \Glsentrylong{##1}##2\space
   ({\glsentryuseri{##1}\glsentryshort{##1}})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glsentrylongpl{##1}##2\space
   ({\glsentryuseri{##1}\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \Glsentrylongpl{##1}##2\space
   ({\glsentryuseri{##1}\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\acronymentry}[1]{%
   {\glsentryuseri{##1}\glsentryshort{##1}}}%
}

\setacronymstyle{long-alt-short}

\newacronym{ac}{ac}{Alternating Current}
\newacronym[user1=\scshape]{mosfet}{mosfet}{Metal Oxide Semiconductor Field Effect Transistor}

\makeglossaries

\begin{document}

\printglossary[type=\acronymtype,title=Abbreviations]

\gls{mosfet} is supposed to be written in small caps but \gls{ac} is not.

Next use:

\gls{mosfet} is supposed to be written in small caps but \gls{ac} is not.

\end{document}

This stores the font declaration in the user1 key. If this key hasn't been set (as with the ac entry) no font change is performed. As @lockstep pointed out \sc is obsolete so I've replaced it with \scshape. The resulting document looks like:

image of resulting document

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.