是否可以将新命令的“结果”与 ulem 包的 sout 命令结合起来并使用换行符/连字符?
\documentclass{article}
\usepackage{ulem,lipsum}
\textwidth=3cm % just to force hyphenation/linebreaks to happen
\usepackage[T1]{fontenc}
\begin{document}
\sout{The sout makro of ulem is able to handle hyphenation and linebreaks in text entered directly but not as macro see next line!}
\sout{\lipsum[1]}
\newcommand\test{Nore does it work with a simple macro text.}
\sout{\test}
\end{document}
正如 TeXnician 以最简单的形式建议的那样,它的工作原理如下:
\newcommand\souttest{\expandafter\sout\expandafter{\test}}
\souttest
我尝试将其应用于我的情况,但情况略微复杂一些。我定义了一个 Lyx“本地格式”来突出显示文本并进行注释,以便可以方便地执行 QCAmap 并减少 Lyx 中的 ERT!因此,问题的简单版本是:
\expandafter\newcommand\csname soutAutoP\endcsname{\expandafter\sout\expandafter{\csname test\endcsname}}
\soutAutoP
对于那些感兴趣的人来说,长版本如下:
InsetLayout Flex:Kategorie
LyxType charstyle
LabelString kategorie
LatexType command
LatexName kategorie
Argument 1
Decoration conglomerate
LabelString "Name"
Tooltip "Eindeutiger Kategorie Name"
Mandatory 1
EndArgument
Argument 2
LabelString "Phra"
Tooltip "Text der Phrase"
Mandatory 1
EndArgument
Argument 3
LabelString "Gen"
Tooltip "Text der Generalisierung"
Mandatory 1
EndArgument
Preamble
\usepackage{ifthen}
\usepackage[dvipsnames]{xcolor}
\newcommand{\KatFarbe}[1]
{
\ifthenelse{\equal{#1}{A}}{\colorlet{myColor}{blue}}{%
\ifthenelse{\equal{#1}{B}}{\colorlet{myColor}{lime}}{%
\ifthenelse{\equal{#1}{C}}{\colorlet{myColor}{orange}}{%
\ifthenelse{\equal{#1}{D}}{\colorlet{myColor}{cyan}}{%
\ifthenelse{\equal{#1}{E}}{\colorlet{myColor}{purple}}{%
\ifthenelse{\equal{#1}{F}}{\colorlet{myColor}{red}}{%
\ifthenelse{\equal{#1}{G}}{\colorlet{myColor}{magenta}}.{\colorlet{myColor}{gray}}}}}}}}
}
\usepackage{xstring}
\usepackage{tikz}
\usepackage[normalem]{ulem}
\newcommand\encircle[1]{%
\tikz[baseline=(X.base)]
\node (X) [draw, shape=circle, inner sep=0] {\strut #1};}
\newcommand{\kategorie}[4]{%
\expandafter\gnewcommand\csname Kat#1\endcsname{\hspace{0pt}#4}%
\expandafter\gnewcommand\csname Kat#1P\endcsname{\hspace{0pt}#2}%
\expandafter\gnewcommand\csname soutKat#1P\endcsname{\expandafter\sout\expandafter{\csname Kat#1P\endcsname}}%
\expandafter\gnewcommand\csname Kat#1G\endcsname{\hspace{0pt}#3}%
\StrLeft{#1}{1}[\myKat]\KatFarbe{\myKat}\linelabel{lne:#1}\linelabel{lne:#1Start}\textcolor{myColor!80!black}{\expandafter\csname Kat#1\endcsname$^{\tiny\encircle{\myKat}}$}\linelabel{lne:#1Stop}}
EndPreamble
End
要使用 sout 访问简化的文本,可以这样写:
\expandafter\sout\expandafter{\KatCSexEtwP}
%to reduce the ERT I tried to combine it to
\soutKatCSexVsKoerperP
但我失败了。至于 TeXnician 的问题,说实话我不知道,因为我对 TeX 了解不多。抱歉!
抱歉,代码中含有德语。
答案1
像您的示例中那样,一个简单的新命令很容易,只需添加\expandafter
(顺便说一下,这对以下情况不起作用\lipsum
):
\documentclass{article}
\usepackage{ulem,lipsum}
\textwidth=3cm % just to force hyphenation/linebreaks to happen
\usepackage[T1]{fontenc}
\begin{document}
\sout{The sout makro of ulem is able to handle hyphenation and linebreaks in text entered directly but not as macro see next line!}
\sout{\lipsum[1]}
\newcommand\test{Nore does it work with a simple macro text.}
\expandafter\sout\expandafter{\test}
\end{document}