New answers tagged

9

When using modern fonts in conjunction with LuaLaTeX or XeLaTeX, one is (sometimes) able to delegate this this to the font, since OpenType Layout defines a font feature c2sc that translates capital letters to small cap letters. Unfortunately, Latin Modern does not contain this feature. When available, one can activate this via fontspec feature Letters=...


8

Using uppercase in the input to mean small caps in the output: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\famword}{m} { \tl_set:Nn \l_tmpa_tl { #1 } \regex_replace_all:nnN { ([A-Z]+) } { \c{spark_lc:n}\cB\{\1\cE\} } \l_tmpa_tl \tl_use:N \l_tmpa_tl } \cs_new_protected:Nn \spark_lc:n { \textsc { \tl_lower_case:n { #...


8

Here's a LuaLaTeX-based solution. It consists of (a) a main Lua function called uc2sc (short for "uppercase to smallcaps", I suppose) and an auxiliary Lua function called makesc which, together, do most of the work and (b) a LaTeX macro called \famword that acts as a wrapper for the uc2sc function. The Lua functions employ Lua's versatile built-in string....


15

The tokcycle package (https://www.ctan.org/pkg/tokcycle) can be used for this. \documentclass{article} \usepackage{tokcycle} \newcommand\famword[1]{% \resettokcycle% \Characterdirective{\ifcat A##1\ifnum`##1<`Z\addcytoks{% \textsc{\char\numexpr32+`##1\relax}}\else \addcytoks{##1}\fi\else\addcytoks{##1}\fi}% \tokcyclexpress{#1}% \the\...


Top 50 recent answers are included