Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass{scrartcl}
- usepackage{lmodern}
- usepackage{array}
- usepackage{booktabs}
- usepackage{tabu}
- % First attempt:
- usepackage{xstring}
- newcommand{tosfescapestep}[2]{%
- expandafterStrSubstituteexpandafter{x}{#1}{#2}[x]%
- }
- newcommand{tosfescapehelper}[1]{{%
- noexpandarg % suppress expansions made by xstring
- StrSubstitute{#1}{0}{oldstylenums{1}}[x]% first step
- tosfescapestep{1}{oldstylenums{1}}%
- tosfescapestep{2}{oldstylenums{2}}%
- tosfescapestep{3}{oldstylenums{3}}%
- tosfescapestep{4}{oldstylenums{4}}%
- tosfescapestep{5}{oldstylenums{5}}%
- tosfescapestep{6}{oldstylenums{6}}%
- tosfescapestep{7}{oldstylenums{7}}%
- tosfescapestep{8}{oldstylenums{8}}%
- tosfescapestep{9}{oldstylenums{9}}%
- x}}
- newcommand{tosfescape}[1]{tosfescapehelper{#1}}
- % Second attempt:
- usepackage{xparse}
- usepackage{expl3}
- %usepackage{l3regex}
- ExplSyntaxOn
- NewDocumentCommand tosfdemo { m }%
- { tosfdemo_helper:n { #1 } }
- tl_new:N l_tosfdemo_tl
- cs_new:Npn tosfdemo_helper:n #1 {
- tl_set:Nn l_tosfdemo_tl {#1}
- regex_replace_all:nnN { (d+) } { c{oldstylenums}cB{ 1 cE} } l_tosfdemo_tl
- tl_use:N l_tosfdemo_tl
- }
- ExplSyntaxOff
- begin{document}
- noindent Braces -- bold, first and second attempt to texttt{oldstylenums} textbf{work}:\[medskipamount]
- textbf{bold 1 23}\
- tosfescape{first 1 23}\
- tosfdemo{second 1 23}bigskip
- noindenttexttt{textbackslash bgroup} & texttt{textbackslash egroup} -- as in table~ref{tab:1}, bold textbf{works}, first and second attempt to texttt{oldstylenums} textbf{does not work}:\[medskipamount]
- textbfbgroup bold 1 23egroup\
- tosfescapebgroup first 1 23egroup\
- tosfdemobgroup second 1 23egroup
- begin{table}[h]
- centering
- caption{Bold textbf{works}, first and second attempt to texttt{oldstylenums} textbf{does not work}}
- label{tab:1}
- begin{tabu}{c >{textbfbgroup}c<{egroup} >{tosfescapebgroup}c<{egroup} >{tosfdemobgroup}c<{egroup}}
- %toprule
- rowfont{itshapebfseries} no change & texttt{textbackslash textbf} & texttt{textbackslash tosfescape} & texttt{textbackslash tosfdemo} \
- midrule
- regular 1 23 & bold 1 23 & first 1 23 & second 1 23 \
- %bottomrule
- end{tabu}
- end{table}
- end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement