0

Right now I've got commands defined in my preamble that abbreviate \mathbf. For example, instead of writing \mathbf{F} every time I want to write F, I've simply defined a new command \def\F{\ensuremath{\mathbf{F}}} so I can write F more easily as \F.

Thing is, I'm doing this for lots of letters and it would be much nicer if I could cover the whole alphabet in one or two commands.

So is there something like \def\[lowercase]{\ensuremath{\mathbf{[lowercase]}}} where whenever I write \ followed by a lowercase letter it will compile that lowercase letter in bold?

It's not really a big deal having several similar commands in the preamble as I can just copy and paste and change accordingly, but it would be nice to have something more concise.

Thanks in advance for the help.

1 Answers1

0

This declares a command for each lowercase letter in the alphabet. Existing commands are overwritten, which might be a problem as @DavidCarlisle mentions in the comments.

\documentclass{article}

\ExplSyntaxOn \clist_map_inline:nn {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z} { \exp_args:Nc \DeclareDocumentCommand {#1} {} {\ensuremath{\mathbf{#1}}} } \ExplSyntaxOff

\begin{document} \a \f \n \h \z \end{document}

enter image description here

  • a,b,c,d,h,i,k,l,o,r,u,v are all standard latex commands, typsetting a bibliography with non english names will produce weird results after such a definition. – David Carlisle Jun 27 '22 at 22:10
  • @DavidCarlisle Would you link to something explaining a bit more about core commands? I had never used \[lowercase] for anything until I wanted to use it for bold, so I was unaware that it would be overriding anything. (I didn't get any error messages when I used the new commands, so...) – GibbNotGibbs Jun 28 '22 at 09:36
  • 1
    @GibbNotGibbs \c for example is cedilla \c{c} is ç even if you use inputenc and enter abç latex first normalises this to ab\c{c} then this will produce abcc with no warning, so basically if your document is not in English, or even if it is in English but your bibliography references any person or title with an accented letter, latex is fudamentally broken by these definitions. The fact that you get no error using these commands is the problem not a sign that everything is OK. – David Carlisle Jun 28 '22 at 11:00