后续行动我之前的问题,我想发出以下命令\chickenize
:
适用草案选择权
graphicx
Question 1
将表格内的文本super
等每个单词转换sub
为虚拟单词。
\documentclass{exam}
\usepackage{luacode}
\usepackage{graphicx}
\usepackage{chickenize}
\begin{luacode*}
chickenizefraction = 100000
chickenstring[1] = "xxxx"
chickenstring[2] = "x"
chickenstring[3] = "xx"
chickenstring[4] = "xxxxx"
\end{luacode*}
\qformat{Question \thequestion\hfill}
\begin{document}
\chickenize
\begin{questions}
\question[7]
some text to be replaced by a dummy one \textsuperscript{super} \textsubscript{sub}.
\includegraphics[width=0.25\linewidth]{example-image}\vspace{\baselineskip}
\begin{tabular}{c}
\hline
some text\\
another text\\
\hline
\end{tabular}
\end{questions}
\end{document}
更新 1
考虑到 Therese 的建议评论指的是这个问题,以下方法(使用条件\ifPublicPrinter
)需要:
转换所有数学文本/符号/数字
删除草稿图像的打印路径
\newif\ifPublicPrinter
\PublicPrintertrue
\ifPublicPrinter
\PassOptionsToPackage{draft}{graphicx}
\fi
\documentclass[addpoints]{exam}
\usepackage{luacode,fontspec}
\usepackage{graphicx}
\usepackage{unicode-math,siunitx}
\ifPublicPrinter
\setmainfont{redacted-script-regular.ttf}
\setmathfont{redacted-script-regular.ttf}
\fi
\qformat{Question \thequestion\ (\totalpoints)\hfill}
\begin{document}
\begin{questions}
\question[7]
some text to be replaced by a dummy one \textsuperscript{super} \textsubscript{sub}.
\includegraphics[width=0.25\linewidth]{example-image}\vspace{\baselineskip}
\underline{$\symbf{\Delta V \leq 5}~ \si{\kilo\m\per\hour}$}
\[\num{-8e-06}~N_e^2 + {0.072}~N_e - \beta\]
\begin{tabular}{c}
\hline
some text\\
another text\\
\hline
\end{tabular}
\end{questions}
\end{document}
答案1
目前还不完全清楚您所期望的输出的范围和目的,因此我会尝试并等待您真正想要的反馈。
我在这里所做的是用经过example-image
拉伸和缩放以占据与原始字母相同的空间的标记替换每个 catcode 11 标记。
至于图形,我重新定义\includegraphics
为始终输出通用图像,而不是指定的图像。
请注意,某些类型的文本需要在|
分隔符之间进行转义,以避免替换,例如环境名称和宏参数。这取决于用户是否确定。
\documentclass{exam}
\usepackage{tokcycle,graphicx}
\tokcycleenvironment\chickenize
{\tctestifcatnx a##1{%
\setbox0=\hbox{##1}%
\edef\tmp{[width=\the\wd0, height=\the\dimexpr\ht0+\dp0\relax]}%
\addcytoks[1]{\expandafter\raisebox\expandafter{\expandafter-\the\dp0}}%
\addcytoks[1]{\expandafter{%
\expandafter\includegraphics\tmp{example-image-a}}}}{%
\addcytoks{##1}}}
{\processtoks{##1}}
{\addcytoks{##1}}
{\addcytoks{##1}}
\let\svincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{\svincludegraphics[#1]{example-image-c}}
\begin{document}
\chickenize
This is a \textit{test} of descenders yig.
Of a substitute font with math:
|\hspace{.5in}|$y = mx^{2x} + b_{a}$
|\begin{questions}|
\question[7]
some text to be replaced by a dummy one \textsuperscript{super} \textsubscript{sub}.
|\includegraphics[width=0.25\linewidth]{example-image-a}|%
\vspace{\baselineskip}
|\begin{tabular}{c}|
\hline
some text\\
another text\\
\hline
|\end{tabular}|
|\end{questions}|
\endchickenize
\end{document}
如果您希望输出的是文本而不是缩放的图像,这里我只需将每个 catcode 11 标记替换为x
。此外,我将每个数字转换为0
,同时保留所有其他标点符号。
\documentclass{exam}
\usepackage{tokcycle,graphicx}
\tokcycleenvironment\chickenize
{\tctestifcatnx a##1{%
\addcytoks{x}}{%
\tctestifnum{`##1>`/}{\tctestifnum{`##1<`:}{%
\addcytoks{0}}{\addcytoks{##1}}}{\addcytoks{##1}}}}
{\processtoks{##1}}
{\addcytoks{##1}}
{\addcytoks{##1}}
\let\svincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{\svincludegraphics[#1]{example-image-c}}
\begin{document}
\chickenize
This is a \textit{test} of descenders yig.
Of a substitute font with math:
|\hspace{.5in}|$y = mx^{2x} + b_{5}$
|\begin{questions}|
\question[7]
some text to be replaced by a dummy one \textsuperscript{super} \textsubscript{sub}.
|\includegraphics[width=0.25\linewidth]{example-image-a}|%
\vspace{\baselineskip}
|\begin{tabular}{c}|
\hline
some text\\
another text\\
\hline
|\end{tabular}|
|\end{questions}|
\endchickenize
\end{document}
在评论中,原作者对必须转义许多宏参数的想法很不满意。当然,问题是有些宏参数,例如\begin{tabular}
,你不想转义\chickenize
,而有些,例如,你想转义。最后,用户必须决定如何继续,但下面我提供了一种替代方案,其中所有组内容都明确地从鸡化中省略。因此,例如\textit{test}
,人们不再需要转义。\begin{tabular}
但是,可选的宏参数(用 分隔)[...]
仍必须进行转义(例如\includegraphics
下面 MWE 中的选项)。此外,如果希望有选择地将宏参数简化,则必须通过嵌套重新调用它(如 的情况\textit{\chickenize test\endchickenize}
)。
\documentclass{exam}
\usepackage{tokcycle,graphicx}
\tokcycleenvironment\chickenize
{\tctestifcatnx a##1{%
\addcytoks{x}}{%
\tctestifnum{`##1>`/}{\tctestifnum{`##1<`:}{%
\addcytoks{0}}{\addcytoks{##1}}}{\addcytoks{##1}}}}
{\addcytoks{##1}}
{\addcytoks{##1}}
{\addcytoks{##1}}
\let\svincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{\svincludegraphics[#1]{example-image-c}}
\begin{document}
\chickenize
This is a \textit{\chickenize test\endchickenize} of descenders yig.
Of a substitute font with math:
\hspace{.5in}$y = mx^{\chickenize2x\endchickenize} + b_{\chickenize5\endchickenize}$
\begin{questions}
\question[7]
some text to be replaced by a dummy one \textsuperscript{%
\chickenize super\endchickenize} \textsubscript{\chickenize sub\endchickenize}.
\includegraphics|[width=0.25\linewidth]|{example-image-a}%
\vspace{\baselineskip}
\begin{tabular}{c}
\hline
some text\\
another text\\
\hline
\end{tabular}
\end{questions}
\endchickenize
\end{document}
ps 对于使用此()包的另一个相关答案tokcycle
,如果您希望用不同的字母替换每个字母:LaTeX Uglifier/混淆器
答案2
在更新中,要将字体应用于所有数学文本/符号/数字,您可以添加以下setmathfont
命令:
\ifPublicPrinter
\setmainfont{redacted-script-regular.ttf}
\setmathfont{redacted-script-regular.ttf}
\setmathfont[range=\mathup/{num}]{redacted-script-regular.ttf}
\setmathfont[range=\mathrm]{redacted-script-regular.ttf}
\setmathfont[range=\mathit]{redacted-script-light.ttf}
\setmathfont[range=\mathbf]{redacted-script-bold.ttf}
\setmathfont[range={"2032}]{redacted-script-regular.ttf}
\fi
答案3
感谢 Steven 的鼓舞人心的答案,下面正是我所需要的:
\newif\ifPublicPrinter
\PublicPrintertrue
\ifPublicPrinter
\PassOptionsToPackage{draft}{graphicx}
\fi
\documentclass[addpoints]{exam}
\usepackage{luacode,fontspec}
\usepackage{graphicx}
\usepackage{unicode-math,siunitx}
\ifPublicPrinter
\setmainfont{redacted-script-regular.ttf}
\setmathfont{Cambria Math}
\setmathfont{redacted-script-regular.ttf}%
[range = {up , it , bb , bbit , scr , cal , bfcal , frak , tt , sfup ,
sfit , bfup , bfit , bfscr , bffrak , bfsfup , bfsfit, {"002B}, {"002D}, {"2796}, {"207B}}]
\let\svincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{\svincludegraphics[#1]{example-image}}
\fi
\qformat{Question \thequestion\ (\totalpoints)\hfill}
\begin{document}
\begin{questions}
\question[7]
some text to be replaced by a dummy one \textsuperscript{super} \textsubscript{sub}.
\includegraphics[width=0.25\linewidth]{example-image}\vspace{\baselineskip}
\underline{$\symbf{\Delta V \leq 5}~ \si{\kilo\m\per\hour}$}
\[\num{-8e-06}~N_e^2 + {0.072}~N_e - \beta\]
\begin{tabular}{c}
\hline
some text\\
another text\\
\hline
\end{tabular}
\end{questions}
\end{document}