I'm working on a paper that deals with foreign words and a lot of diacritics. To help with this, I've created a series of macros, so that if I write \wufen it comes out as "wǔfēn". Usually this is mid-sentence, so that's fine. However in a few cases, I've got the following:

    \item \wufen something something
    \item Something \wufen something...

Is there a way to force \items to always capitalise the first letter? I want to see this as the result of the above:

Wǔfēn something something

• Something wǔfēn something...

Is this possible?

I'm relatively new to LaTeX so apologies if this is a terrible question. I'm honestly not too clear on what I should be searching for, though past attempts haven't produced anything yet.

  • 6
    Why not make uppercase versions of your macros? \Wufen etc. and use these. – Alan Munn Nov 28 '13 at 12:41
  • Why not to use unicode and get rid of these macros? /holding the AGAINST MACROS FOR WORDS sign very high... – yo' Nov 28 '13 at 14:01
  • 3
    @tohecz if you plan on saying that often you could use \def\amfw{AGAINST MACROS FOR WORDS} :-) – David Carlisle Nov 28 '13 at 14:07
  • @DavidCarlisle As a person who often reads code of others: no, never! – yo' Nov 28 '13 at 14:17
  • @AlanMunn It kinda defeats the purpose of the shorthand then. What I'm hoping to be able to do is change all cases of the macro once, so maybe before I finish, I decide I want "wǔfen" to be "wuufen", and I only have to change it in one place. In this case the macro is for reflecting a word under a certain romanisation system and I'd like to be able to switch systems without too much trouble. – Yhilan Mar 4 '14 at 6:54

Please always post complete documents, not just fragments.

enter image description here

TeX is in vertical mode at that point, so you can do:


\newcommand\wufen{\ifvmode W\else w\fi ufen}


    \item \wufen\ something something
    \item Something \wufen\ something...

  • +1 so kool! Would \ifvmode\expandafter\uppercase\fi wufen work? – yo' Nov 28 '13 at 13:59
  • 2
    @tohecz no because uppercase needs explict {} but you don't need the \expandafter either so you can do \newcommand\wufen{\ifvmode \uppercase\else \lowercase\fi {w}ufen} if you want. (you need the lowercase to remove the {} so as not to break any inter-letter kerns. – David Carlisle Nov 28 '13 at 14:02
  • ok, so \MakeUppercase ... – yo' Nov 28 '13 at 14:03
  • @tohecz \MakeUppercase wufen produces {W}ufen so would break any kern between W and u – David Carlisle Nov 28 '13 at 14:05
  • damn, always problems. Seems that your original one is the best. I only don't like the fact that you have to seperate the first letter of the word... – yo' Nov 28 '13 at 15:09

Personally I would use uppercase versions of the macros as suggested in the comments. However, if you want to do it automatically, you could use the command \capitalize from the stringstrings package.



\newcommand{\citem}{\item \capitalize}

\newcommand{\abc}{abcdefghijklmnopqrstuvwxyz} % A simple macro


    \item Abc % for comparison
    \citem abc % capitalize 
    \citem Abc % no effect if already capitalized
    \citem \abc % works for simple macros

  • If you wanted something that works for "complicated macros", go for {\item\expandafter\uppercase} or {\item\expandafter\capitalize}. However, your current approach kills the optional argument to \item. – yo' Nov 28 '13 at 13:58
  • @tohecz: I fully agree. To save the optional argument one could do something like \newcommand{\citem}[1][\stepcounter{enumi}\labelenumi]{\item[#1] \capitalize}, which is quite messy. Hence +1 for David Carlisle's elegant solution. – crixstox Nov 28 '13 at 14:29

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.