Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass{article}
- \usepackage{xparse,xcolor}
- \usepackage{ebgaramond} % fully scalable font
- \usepackage{verbatim}
- % egreg @ https://tex.stackexchange.com/questions/338364/
- % egreg @ https://tex.stackexchange.com/questions/514372/
- \ExplSyntaxOn
- \keys_define:nn { mystyle }
- {
- color .tl_set:N = \l__mystyle_color_tl,
- size .tl_set:N = \l__mystyle_size_tl,
- skip .tl_set:N = \l__mystyle_skip_tl,
- color .initial:n = red,
- size .initial:n = 1,
- skip .initial:n = 1,
- }
- \cs_new_eq:NN \optical_fontsize:nn \fontsize
- \cs_generate_variant:Nn \optical_fontsize:nn { ee }
- \NewDocumentCommand{\setmyfontsize}{ m O{1.2} }
- {
- \optical_fontsize:ee
- { \fp_eval:n { \use:c { f@size } + #1 } }
- { \fp_eval:n { ( \use:c { f@size } + #1 ) * ( #2 ) } }
- \selectfont
- }
- \NewDocumentCommand{\stress}{ O{} m }
- {
- \group_begin:
- \keys_set:nn { mystyle } { #1 }
- \clist_map_inline:nn { #2 }
- {
- \mystyle:VVVn
- \l__mystyle_color_tl
- \l__mystyle_size_tl
- \l__mystyle_skip_tl
- {##1}
- }
- \group_end:
- }
- \cs_new_protected:Nn \mystyle:nnnn
- {
- \setmyfontsize{#2}[#3]\textcolor{#1}{#4}
- }
- \cs_generate_variant:Nn \mystyle:nnnn { VVV }
- \ExplSyntaxOff
- \begin{document}
- \stress{emphasize this sentence with default values and add extra characters to check the default baselineskip}
- \bigskip
- \stress[color=green,size=-1]{\textit{emphasize this sentence with custom color and size values}}
- \bigskip
- \stress[color=red,size=1]{emphasize this sentence with default color and size values set explicitly and check the resulting baselineskip: should be the same baselineskip as on the first line}
- \bigskip
- \stress[color=blue,size=3]{emphasize this sentence with custom color and size values and check the default baselineskip for this size: should have bigger font and bigger baselineskip than above}
- \bigskip
- \stress[color=blue,size=3, skip=2]{emphasize this sentence with custom color size and baseline skip values and check the result: should have bigger font and much bigger baselineskip than above}
- \bigskip
- \stress[color=gray,size=3]{notice how a comma messes things, notice how a comma messes things}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment