我有一长串字符,其中包含通过颜色框突出显示的文本。其中的字符\seqsplit
被忽略。如何强制在突出显示的文本中换行?
请注意:\seqsplit
不允许在其环境中使用任何其他命令。因此,当我将\seqsplit
命令放在 之外时,会出现错误\colorbox
。
\documentclass{scrreprt}
\usepackage{seqsplit}
\usepackage{xcolor}
\newcommand{\reducedstrut}{\vrule width 0pt height .9\ht\strutbox depth .9\dp\strutbox\relax}
\newcommand{\yellow}[1]{%
\begingroup
\setlength{\fboxsep}{0pt}%
\colorbox{yellow}{\reducedstrut#1\/}%
\endgroup
}
\begin{document}
\seqsplit{TAAGAACTACTCTTTGGAGCATGTCATCATAGATCCATATTTCAATCGAATTACTTCTCAGATGCGTAGTTGTGGAGAAGATGTCACAGAAATCGAAGTGAAACCTGATGGTTCTTGGCGCGCGAAGACAGAATC}
\yellow{\seqsplit{ACACTGCACGGTATGCTCCTCTTCTTGTTCATGGTCATGATCCTTATATGAGCAGGGAAAGTCCAGTTTAGACTTGTAGTTAGTTACTCTTCGTTATAGGATTTGGATTTCTTGCGTGTTTATGGTTTTAGTTTCCCTCCTTTGATGAATAAAATTGAATCTTGTATGAGTTTCATATCCATGTTGTGAATCTTTTTGCAGACGCAGCTAG}}
\seqsplit{GATTCTGTCTTCGCGCGCCAAGAACCATCAGGTTTCACTTCGATTTCTGTGACATCTTCTCCACAACTACGCATCTGAGAAGTAATTCGATTGAAATATGGATCTATGATGACATGCTCCAAAGAGTAGTTCTTAAGACAGATAGGGCATTGCCACTTCCTCGACCTTTGATTCATTTCAACAAAGACGTCAAGATCAAAGCAGCCCATGTGTATACAAGGTTTGAATCTTCCAGCAACTTTCATCCCCC}
\end{document}
答案1
你可以强迫soul
合作,但不能seqsplit
。
\documentclass{scrreprt}
\usepackage{soul}
\usepackage{xcolor}
\ExplSyntaxOn
\NewDocumentCommand{\seqsplit}{om}
{
\group_begin:
\setlength{\spaceskip}{0pt plus 0.2pt}
\__carl_seqsplit_load:n { #2 }
\IfNoValueTF { #1 }
{
\__carl_seqsplit_simple:
}
{
\__carl_seqsplit_color:n { #1 }
}
\hspace{\spaceskip}
\group_end:
}
\seq_new:N \l__carl_seqsplit_seq
\cs_new_protected:Nn \__carl_seqsplit_load:n
{
\seq_set_split:Nnn \l__carl_seqsplit_seq { } { #1 }
}
\cs_new:Nn \__carl_seqsplit_simple:
{
\seq_use:Nn \l__carl_seqsplit_seq { ~ }
}
\cs_new_protected:Nn \__carl_seqsplit_color:n
{
\sethlcolor{#1}
\AddToHook{cmd/SOUL@hlpreamble/after}{\setlength{\spaceskip}{0pt plus 0.2pt}}
\exp_args:Ne \hl { \__carl_seqsplit_simple: }
}
\ExplSyntaxOff
\begin{document}
\seqsplit{TAAGAACTACTCTTTGGAGCATGTCATCATAGATCCATATTTCAATCGAATTACTTCTCAGATG%
CGTAGTTGTGGAGAAGATGTCACAGAAATCGAAGTGAAACCTGATGGTTCTTGGCGCGCGAAGACAGAATC}%
\seqsplit[yellow]{ACACTGCACGGTATGCTCCTCTTCTTGTTCATGGTCATGATCCTTATATGAGCAGG%
GAAAGTCCAGTTTAGACTTGTAGTTAGTTACTCTTCGTTATAGGATTTGGATTTCTTGCGTGTTTATGGTTT%
TAGTTTCCCTCCTTTGATGAATAAAATTGAATCTTGTATGAGTTTCATATCCATGTTGTGAATCTTTTTGCAGACGCAGCTAG}%
\seqsplit{GATTCTGTCTTCGCGCGCCAAGAACCATCAGGTTTCACTTCGATTTCTGTGACATCTTCTCCAC%
AACTACGCATCTGAGAAGTAATTCGATTGAAATATGGATCTATGATGACATGCTCCAAAGAGTAGTTCTTAA%
GACAGATAGGGCATTGCCACTTCCTCGACCTTTGATTCATTTCAACAAAGACGTCAAGATCAAAGCAGCCCA%
TGTGTATACAAGGTTTGAATCTTCCAGCAACTTTCATCCCCC}
\end{document}