A question very similar to mine was asked before, but I assume that there are others with the same issue and that there are other solutions. I know several academic publishers that don't like excessive use of capital letters in running text as it distracts heavily from reading. Instead, they use small caps for all-caps abbreviations and highlighted words.

As I am writing a tex-template for future use, I need a solution that affects all all-caps words without having to alter the .tex-file. Moreover, this others having the same problem can take over the same solution without easily.

Goal: convert all all-caps words in a document into all small-caps.


  • We need to determine all-caps words and their boundaries before we can convert them.
  • In most cases, the complete word needs to be in small-caps, including the first letter (as if \textsc{\MakeLowercase{#1}}), though some prefer the first letter to be a capital (as in answer to the question asked before).
  • A plural form of the abbreviations (e.g., URLs, CDs) contains an suffixed s, which should remain lowercase (as it always is).

Solutions: I have looked for various ways to solve this, but none gave me the correct solution yet.

  • using Lua code (in LuaLaTeX; cf. Lua Frontier Pattern and Macro: Replace all occurrences of a word). However, the following code does not work, possibly because it also affects LaTeX commands (I have been thinking to ignore/escape \, just as I would need to do with word-final -s).

      function capstosc ( s )
        return unicode.utf8.gsub( s, "(%f[%a]%u+%f[%A])" , "{\\scshape\\MakeLowercase{#1}}")
      \directlua{luatexbase.add_to_callback ( 
        "process_input_buffer", capstosc, "capstosc" )}
  • l3regex (with a similar RegEx search entry as above) but I have not found any way to apply this to the whole document text;

  • a custom-made TeX-code; the other question has an answer that provides this, but it cannot be applied to the entire document and it does not seem to be able to be adjusted to ignore plural s's.

  • How to handle the case of an all-caps word being the result of expanding a macro which is defined in an external package? – Ulrich Diez Jan 2 at 11:27
  • 2
    This is a great idea. Maybe someone could write a package. – Jesse Knight Jan 2 at 15:58
  • Yeah process_input_buffer is not a good callback to use; probably pre_linebreak_filter or something else will work better (and address the problem @UlrichDiez mentioned above). Of course then it's not a simple string substitution and you'd have to do more work. – ShreevatsaR Jan 3 at 5:16
  • Can you clarify what you mean by “However, the following code does not work, possibly because it also affects LaTeX commands”? What does “does not work” mean here, and do you have LaTeX commands with caps in them that were being modified, and which you want to ignore? – ShreevatsaR Jan 6 at 9:38
  • @UlrichDiez ideally that would be affected as well. The typographic style simply forbids all-caps words. But I understand that is an extra difficulty. – Jopie 2 days ago

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.