Convert all all-caps words to small caps #2
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.
Issues:
- 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).
usepackage{luacode}
begin{luacode}
function capstosc ( s )
return unicode.utf8.gsub( s, "(%f[%a]%u+%f[%A])" , "{\scshape\MakeLowercase{#1}}")
end
end{luacode}
AtBeginDocument{%
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.
luatex capitalization small-caps lua l3regex
add a comment |
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.
Issues:
- 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).
usepackage{luacode}
begin{luacode}
function capstosc ( s )
return unicode.utf8.gsub( s, "(%f[%a]%u+%f[%A])" , "{\scshape\MakeLowercase{#1}}")
end
end{luacode}
AtBeginDocument{%
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.
luatex capitalization small-caps lua l3regex
add a comment |
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.
Issues:
- 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).
usepackage{luacode}
begin{luacode}
function capstosc ( s )
return unicode.utf8.gsub( s, "(%f[%a]%u+%f[%A])" , "{\scshape\MakeLowercase{#1}}")
end
end{luacode}
AtBeginDocument{%
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.
luatex capitalization small-caps lua l3regex
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.
Issues:
- 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).
usepackage{luacode}
begin{luacode}
function capstosc ( s )
return unicode.utf8.gsub( s, "(%f[%a]%u+%f[%A])" , "{\scshape\MakeLowercase{#1}}")
end
end{luacode}
AtBeginDocument{%
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.
luatex capitalization small-caps lua l3regex
luatex capitalization small-caps lua l3regex
edited 6 mins ago
AboAmmar
32.8k22882
32.8k22882
asked 9 mins ago
Jopie
302312
302312
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467544%2fconvert-all-all-caps-words-to-small-caps-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467544%2fconvert-all-all-caps-words-to-small-caps-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown