0

Is there a way to force the text of an entire document to be typeset in all upper case with the exception of any math?

  • 6
    Why would you want to do such a thing? :P – Alenanno Jan 10 '16 at 14:57
  • Also, even if you wanted all caps (not small caps), not all characters are supported. \uppercase{\ae} is the same as \ae. – Alenanno Jan 10 '16 at 15:03
  • 3
    @Alenanno That's why \uppercase isn't a latex command, use \MakeUppercase{\ae} – David Carlisle Jan 10 '16 at 15:15
  • If you mean caps and small caps just use \scshape if you want all (large) caps then it would be easiest of you had an all caps font, that usually isn't available. – David Carlisle Jan 10 '16 at 15:18
  • @DavidCarlisle Oh good to know. Are there characters that wouldn't work even then? – Alenanno Jan 10 '16 at 15:19
  • I deleted my comment about \scshape -- I read Small caps instead of All caps ;-) –  Jan 10 '16 at 15:22
  • @Alenanno most of the characters in T1 encoding should work (although best not to ask more than one person what the uppercase of ß is :-) note that your uppercase example would fail even for \def\abc{abc}\uppercase{\abc} but again MakeUppercase would work as it expands before uppercasing – David Carlisle Jan 10 '16 at 15:26
  • To clarify. I am typesetting using fontspec and an OpenType font for a document where I need it to be in ALL CAPS. As an alternative I have been using \uppercase{} surrounding each paragraph and breaking out when I have math but it is a PIA. Looking for a way to apply something like \MakeUppercase but for the whole document – user2501235 Jan 10 '16 at 17:34
  • @user2501235 luatex or xetex? – David Carlisle Jan 10 '16 at 17:35
  • xelatex (but I have no problem using lualatex) – user2501235 Jan 10 '16 at 17:47
  • or you could just use \MakeTextUppercase from my textcase package, which doesn't use any unicode features (would work with pdftex as well) which automatically avoids uppercasing math. – David Carlisle Jan 10 '16 at 19:55
  • I've tried your \MakeTextUppercase but it bombs when paragraphs, sections, environments, etc. begin and end. Requires me to explicitly enclose individual sections of text within curly braces. I am really looking for a simple command that could be placed after \begin{document} and have it carry through. – user2501235 Jan 10 '16 at 20:37
  • @Alenanno, there are characters which do not have uppercase versions. In German, ß and also äüö. In Spanish, until recently there were no uppercase áéíóú, and never has been for ü. I don't know other languages, but I'd be surprised if there weren't other examples. – vonbrand Jan 10 '16 at 22:35
  • @vonbrand Yes but the uppercase version of those letters exists in general. I was more speaking of some symbols/letters that are always lowercase, regardless of the language. – Alenanno Jan 10 '16 at 22:36
  • @Alenanno That a shape exists doesn't make it legal in text in the language. – vonbrand Jan 10 '16 at 22:41
  • @vonbrand I'm aware of that. My question was not limited to this particular post or to a specific language. – Alenanno Jan 10 '16 at 22:47
  • @Alenanno, precisely: Some languages just do not have "uppercase letter equivalents" for all their letters. In such a language this makes no sense. – vonbrand Jan 10 '16 at 23:00
  • @vonbrand Yes, not all lowercase letters have the uppercase variant, but I think you're still missing the point. My question was not about whether a certain letter was legal, but if it existed regardless. For example, as also David mentioned, capital ß does not exist. And it doesn't in any language. That answers my question. – Alenanno Jan 10 '16 at 23:11

1 Answers1

3

In principle you can use the OpenType case feature or its fontspec interface Letters=Uppercase

I can demonstrate with Caps and small Caps

enter image description here

Which comes from

\documentclass{article}

\usepackage{fontspec}

%\setmainfont{TeX Gyre Pagella}[Letters=Uppercase]
\setmainfont{TeX Gyre Pagella}[Letters=SmallCaps]

\begin{document}

One two three $1=0$ and $\theta=x$

\end{document}

However if you switch the commented \setmainfont then you just get lots of warnings looking like

*************************************************
* fontspec warning: "icu-feature-not-exist-in-font"
* 
* OpenType feature 'Letters=Uppercase' (+case) not available for font 'TeX
* Gyre Pagella' with script 'Latin' and language 'Default'.
*************************************************

and the output is just as input with no transformation.

So, if your actual font has the case opentype feature set that's all you need.

If not, then you could view it as a transliteration and use teckit in xetex or a lua callback in luatex, there were recent answers describing this for cyrillic but the system could work for case change as well (don't use my input_buffer callback suggestion for luatex, as you will mess up all the latex commands using lowercase ascii:-)

for xetex

Using XeTeX for automatic transliteration of cyrillic letters

or for luatex

Create a mapping for transliteration from cyrillic to latin in LuaLaTeX

David Carlisle
  • 757,742