32

I found there are many commands in LaTex to satisfy all kinds of requirements of font shape. For example, \textsc{...} for Small Capitals and \uppercase{...} for UPPERCASE, etc. See the following picture, which is form Wikibooks. https://en.wikibooks.org/wiki/LaTeX/Fonts

However, I failed to find a command to make first letter upper case, that is to say, to make first letter upper case as First Letter Upper Case does it exist?

wayne
  • 1,331
  • 4
    I'd say it's an exact duplicate of this question, isn't it? – Robert Seifert Oct 26 '16 at 09:36
  • Please check this: http://tex.stackexchange.com/questions/7992/command-to-uppercase-the-first-letter-of-each-word-in-a-sentence – Ambika Vanchinathan Oct 26 '16 at 09:48
  • @ebo All of them? What about \uppercase? – cfr Oct 30 '16 at 00:56
  • Several of the commands you list are not LaTeX commands at all. They are provided only by certain font support packages. (And isn't \em TeX rather than LaTeX, for example?) – cfr Oct 30 '16 at 00:57
  • Their picture is clearly wrong in several respects e.g. it suggests oblique and italics are the same shape. – cfr Oct 30 '16 at 00:59
  • Thanks for your comments! I am not an expert in the LaTx, I don't know there are many errors in this. As I mentioned in the post, the picture directly obtained from the Wikibooks: https://en.wikibooks.org/wiki/LaTeX/Fonts. Can you list all the wrong respects such that we can make a correction of the Wikibooks for the purpose of benefitting the readers, – wayne Oct 30 '16 at 01:11
  • 1
    See the titlecaps package – Steven B. Segletes Dec 11 '19 at 11:15

2 Answers2

46

Yes, using the mfirstuc package.

\documentclass{article}
\usepackage{mfirstuc}
\begin{document}
\capitalisewords{first letter upper case}
\end{document}

Moreover, one can exclude some words (as "a", "an", "the", "at", "by", "for", etc.) to follow capitalization styles with \MFUnocap{word}

\documentclass{article}
\usepackage{mfirstuc}
\MFUnocap{are}
\MFUnocap{or}
\MFUnocap{etc}
\begin{document}
\capitalisewords{first letters are upper case or lower case, etc}.
\end{document}

In this case, the result should be:

First Letters are Upper Case or Lower Case, etc.

However, note that this package use plain spaces to determine what is a word, so if you exclude "case" will work only in the first match, because the second time the word is really "case," (with a comma).

Alternatively, the titlecaps package can perform the same task but with taking care of the punctuation signs:

\documentclass{article}
\usepackage{titlecaps}
\Addlcwords{are or etc}
\begin{document}
\titlecap{first letters are upper case or lower case, etc.}
\end{document}

The output is exactly the same, but note that the final period was inside the capitalized string and "etc" was correctly not capitalized.

Also note that your mileage may vary with both packages if there are text formatting commands inside the text string, that make the capitalization task much more complex. For example, both packages manage well \textit{xxx}, \emph{xxx} fail only with titlecaps, \itshape xxx fail with only mfirstuc but {\itshape xxx} fail in both packages (although not in the same way).

Fran
  • 80,769
  • 1
    It's also possible to exclude words from case-changing with mfirstuc (e.g. \MFUnocap{etc}). The mfirstuc-english package does this for common English words that shouldn't be case-changed, but you can add additional words as required. – Nicola Talbot Oct 29 '16 at 18:08
  • @NicolaTalbot My apologies for not remember this. I will edit the answer accordingly. – Fran Oct 29 '16 at 21:02
  • 1
    Do you mean correctly not capitalized rather than not capitalized correctly? The latter sounds to me like incorrectly not capitalized but isn't etc. correctly not capitalized? – cfr Oct 30 '16 at 00:54
  • +1. But I agree with cfr. I think you mean: '... "etc" was, correctly, not capitalized'. (Note I am off-setting the 'correctly' here only for emphasis: I'd also suggest 'correctly not capitalized'.) – jon Oct 30 '16 at 03:22
  • @cfr and jon Thanks, It was a typo for lack of sleep. Fixed. – Fran Oct 30 '16 at 05:03
  • I'll have to look at the punctuation problem. Incidentally, there's also a difference between the two packages if there's any markup in argument. For example, first \emph{letters} are upper case or lower case, etc – Nicola Talbot Oct 31 '16 at 11:45
  • @NicolaTalbot. Thanks, I edited the answer to point also this differences ... and thanks also for your packages. – Fran Nov 06 '16 at 04:50
  • if the string to capitalize is in a newcommand, titlecaps works but not mfirstuc, see \newcommand{\myword}{hello } \titlecap{\myword} \capitalisewords{\myword} – citronrose Apr 17 '20 at 09:04
  • I'm trying to use \capitalisewords{\citet{someref}} but it's showing up with missing letters and @ signs. – Alec Jacobson Jan 23 '23 at 14:25
  • @AlecJacobson These commands can fail even with a simple command to use italics. What you expected in a complex command that read in a data base? This is only for a short plain text. I suggest you use JabRef to normalize names in the .bib file. Is only 2-3 clicks in the contextual menu in the author field, but note that names can be printed "as is" in the .bib file, all in uppercase, or in lowercase, depending on the bibliography style that you are using. – Fran Jan 23 '23 at 23:57
  • That doesn't quite solve my use case (which probably deserves its own question if I get around to it): The name is "von Twinkle". In the references or in the middle of a sentence the v should be lowercase. But at the beginning of a sentence my styleguide says it should be capital. So I need \citet{vonTwinkle} to be "von Twinkle [2023]" in the middle of a sentence but \capitalizefirst{\citet{vonTwinkle}} to be "Von Twinkle [2023]" when I use it at the beginning of a sentence. – Alec Jacobson Jan 24 '23 at 21:16
  • @AlecJacobson Indeed it deserves its own question with a MWEB but do not ask about make it work your attempted solution but about any other solution to your actual problem (XY problem), i.e., do not insist on how to make \capitalizefirst work with cites, but in obtain the right format in the cite with bibtex/biblatex by whatever method. – Fran Jan 24 '23 at 22:00
11

you can use \MakeUppercase command,
when you write note={\MakeUppercase accessed:2.3.2019},
the output: Accessed 2.3.2019,
else if you write note={\MakeUppercase {accessed}:2.3.2019},
the output: ACCESSED 2.3.2019,

for example:

@misc{ref5, 
title={Use of Images}, url={https://www.hpl.ca/articles/use-images},
note = {\MakeUppercase  Accessed: 25.10.2019}}
Ulrich Diez
  • 28,770
Alaa
  • 111
  • 1
  • 2