使用 verbatim(不是 Verbatim)来转录手写文件。
我花了很多时间誊写遗嘱、契约、信件和其他手写文件。在誊写过程中,我使用逐字环境,主要是为了让我能够准确地将单词放在需要的位置,以及让长行适合页面宽度的框架。
我已经想出了办法(使用了这个网站上的许多有用提示,谢谢!)来解决逐字记录的限制,以允许使用上标、划线词和脚注等作为参考,正如我将在下面的最小工作示例(MWE)中演示的那样,但我遇到了一个限制,即每个逐字记录环境组一次只能合并两个 catcode。
有谁能为我提供一种在逐字环境中整合更多内容的方法吗?非常感谢您能介绍一下所用的方法。
由于其他原因,我无法在我的工作中使用 Verbatim。
\documentclass[12pt]{memoir}
\usepackage{verbatim}
\usepackage[normalem]{ulem} %used to enable the use of strike out text via \sout{striked out text}
% Footnote treatment, This keeps footnotes flush and aligned to the left.
\setlength{\footmarkwidth}{1.7em} % if your footnotes go into the hundreds, you need at least 1.7em
\setlength{\footmarksep}{0em}
\footmarkstyle{#1.\hfill} % this will give you plain numbers for your notes
\begin{document}
\noindent First Example:
\noindent Escaped Footnote and Superscript within a verbatim environment:
\begingroup{
{\catcode`?=\active
\def?!#1!{\footnote{#1}}
{\catcode`+=\active
\def+!#1!{\textsuperscript{#1}}
\tiny\begin{verbatim}
This is an example of a +!superscript! with subsequent escaped footnotes in a verbatim
environment?!See the First Example!
\end{verbatim}
\normalsize
}}
\normalsize
\noindent
Second Example:
\noindent
Escaped Footnote and sout from the ulem package to line through a word within a
verbatim environment:
\begingroup{
{\catcode`?=\active
\def?!#1!{\footnote{#1}}
{\catcode`+=\active
\def+!#1!{\sout{#1}}
\tiny\begin{verbatim}
This is an example of a +!line of text! group of words being crossed out with
subsequent escaped footnotes in a verbatim environment?!See the Second Example!
\end{verbatim}
\normalsize
}}
\normalsize
\end{document}
这产生以下结果(注意:在上面的消息正文中插入代码块需要我稍微修改一些行的位置,但影响不大)
我希望能够创建一个逐字环境,在其中可以将转义脚注、上标、删除线、高花括号和旧手写文档中发现的许多其他组件全部合并到一个环境中。非常感谢大家的帮助。谢谢!
答案1
你需要 verbatim
完全没有?
\documentclass{article}
\usepackage{alltt}
\usepackage[normalem]{ulem}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentEnvironment{hand}{}
{
\trivlist\ttfamily\footnotesize\raggedright\item
}
{
\endtrivlist
}
\NewDocumentCommand{\?}{m}
{
\str_case:nn { #1 }
{
{!}{ \gentexuser_footnote:w }
{+}{ \gentexuser_sout:w }
{@}{ \gentexuser_textsuperscript:w }
}
}
\cs_new_protected:Npn \gentexuser_footnote:w #1 ! { \footnote{#1} }
\cs_new_protected:Npn \gentexuser_sout:w #1 + { \sout{#1} }
\cs_new_protected:Npn \gentexuser_textsuperscript:w #1 @ { \textsuperscript{#1} }
\ExplSyntaxOff
\setlength{\textheight}{3cm} % just to make a smaller picture
\begin{document}
\begin{hand}
This is an example of a \?@superscript@ with subsequent escaped footnotes in a verbatim
environment\?!See the First Example!
This is an example of a \?+line of text+ group of words being crossed out with
subsequent escaped footnotes in a verbatim environment\?!See the Second Example!
\end{hand}
\end{document}
答案2
这里我直接改编了原作者的verbatim
做法,我将其设为+
一个双参数活动宏,第一个参数定义操作,第二个参数表示参数,因此,+s!superscript!
带有 的s
是上标,+x!subsequent!
带有 的x
是删除线,+f!See the First Example!
带有 的f
是脚注。
\documentclass[12pt]{memoir}
\usepackage{verbatim}
\usepackage[normalem]{ulem} %used to enable the use of strike out text via \sout{striked out text}
% Footnote treatment, This keeps footnotes flush and aligned to the left.
\setlength{\footmarkwidth}{1.7em} % if your footnotes go into the hundreds, you need at least 1.7em
\setlength{\footmarksep}{0em}
\footmarkstyle{#1.\hfill} % this will give you plain numbers for your notes
\textheight 2in
\begin{document}
\noindent Example:
\noindent Escaped Footnote, Superscript AND strikeout
within a verbatim environment:
\begingroup{
{\catcode`+=\active
\def+#1!#2!{\ifx s#1\textsuperscript{#2}\else
\ifx x#1\sout{#2}\else
\ifx f#1\footnote{#2}\fi\fi\fi}
\tiny\begin{verbatim}
This is an example of a +s!superscript! with +x!subsequent! escaped footnotes in a verbatim
environment+f!See the First Example!
\end{verbatim}
\normalsize
}
\end{document}
如果需要一种方法将 a 转义+
到文档中,那么 active+
可以定义为
\def+#1!#2!{\ifx s#1\textsuperscript{#2}\else
\ifx x#1\sout{#2}\else
\ifx f#1\footnote{#2}\else
\ifx +#1\char`+\fi\fi\fi\fi}
在这种情况下将在输出中++!!
产生。+
答案3
有趣的是,使用@egreg 的解决方案,允许使用多字符宏分隔符。
如果我添加另一个案例条件,选择一个(或多或少)不太可能发生的序列,例如spp
,
{spp}{ \gentexuser_spelling:w }
并将匹配的命令定义为
\cs_new_protected:Npn \gentexuser_spelling:w #1 spp { #1\textsuperscript{[spelling?]} }
然后使用\?
以下方式调用宏
\?{spp}Qwertuspp
将第一次出现的spp
分隔符分组放在括号内,以便在呈现给宏时显示为标记,
那么结果是:
(它也不必在环境中hand
。)
要使分隔符以其自身的形式显示,请将它们分组放在括号中以在扫描时隐藏它们:
这种技术可能有用例(例如,无需更改 catcode 的简写?)。
平均能量损失
\documentclass{article}
%\usepackage{alltt}
\usepackage{xcolor}
\usepackage[normalem]{ulem}
\usepackage{xparse}
\let\olddot=\.
\ExplSyntaxOn
\NewDocumentEnvironment{hand}{ +b}
{
% \trivlist\ttfamily\footnotesize\raggedright\item
\trivlist\raggedright\item
#1
\endtrivlist
}
{
}
\NewDocumentCommand{ \? } { m }
{
\str_case:nn { #1 }
{
{!}{ \gentexuser_footnote:w }
{+}{ \gentexuser_sout:w }
{@}{ \gentexuser_textsuperscript:w }
{;}{ \gentexuser_emphfd:w }
{-}{ \gentexuser_arrows:w }
{zy}{ \gentexuser_testxx:w }
{z}{ \gentexuser_testz:w }
{rq}{ \gentexuser_testrq:w }
{spp}{ \gentexuser_spelling:w }
}
}
\RenewDocumentCommand{ \. } { m }
{
\str_case:nn { #1 }
{
{*}{ \gentexuser_hash:w }
}
}
\cs_new_protected:Npn \gentexuser_footnote:w #1 ! { \footnote{#1} }
\cs_new_protected:Npn \gentexuser_sout:w #1 + { \sout{#1} }
\cs_new_protected:Npn \gentexuser_textsuperscript:w #1 @ { \textsuperscript{#1} }
\cs_new_protected:Npn \gentexuser_emphfd:w #1 ; { {\large\textbf{#1}} }
\cs_new_protected:Npn \gentexuser_arrows:w #1 - { $\rightarrow$#1$\leftarrow$ }
\cs_new_protected:Npn \gentexuser_testxx:w #1 zy { ~ABC#1XYZ~ }
\cs_new_protected:Npn \gentexuser_testz:w #1 z { \textit{~zzz#1ZZZ~} }
\cs_new_protected:Npn \gentexuser_testrq:w #1 rq { {\color{blue}rq-Start: [{\bfseries#1}] :rq-End} }
\cs_new_protected:Npn \gentexuser_hash:w #1 * { +++#1+++ }
\cs_new_protected:Npn \gentexuser_spelling:w #1 spp { #1\textsuperscript{[spelling?]} }
\ExplSyntaxOff
%\setlength{\textheight}{3cm} % just to make a smaller picture
\begin{document}
\begin{hand}
This is an example of a \?@superscript@ with subsequent escaped footnotes in a verbatim
environment\?!See the First Example!
This is an example of a \?+line of text+ group of words being crossed out with
subsequent escaped footnotes in a verbatim environment\?!See the Second Example! And some \?;Emphfd text; as well.
And a \?+y{\?@x{\?;combo;}x@}y+.
And a \?+ycomboy+. Some \?-arrows and {-} text-
And \?{zy}xxx qwerty qwerty non-zy \?zUIOPz non-z
This is rq test: some \?{rq}text more textrq and outside rq.
\?{spp}Qwertuspp
\end{hand}
Format is \verb|\?{rq}text more textrq|.
\olddot a \.*b*
To obtain \?{spp}Qwertuspp, type \verb|\?{spp}Qwertuspp|.
And \verb|\?{spp}Qwertu{spp}xyzspp| produces: \?{spp}Qwertu{spp}xyzspp
\end{document}