如何在不使用 Soul Package 的情况下打破段落内的文本下划线

如何在不使用 Soul Package 的情况下打破段落内的文本下划线

考虑以下代码:

\documentclass{book}
\usepackage{soul}

\begin{document}
\thispagestyle{empty}
\large

How may I do this without the \textit{soul} package?\\[7pt]

\ul{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;} 
\end{document}

产生

在此处输入图片描述

问题:如果不使用该包,我该如何做到这一点(在段落内换行下划线)soul

谢谢。

答案1

手稿中的下划线表示通知打印机将文本设置为斜体。

在打字机上,此下划线是通过退格并输入下划线来完成的。

可以通过将压板向上转动半个“行”空间并键入等号来表示更大的强调(例如粗体)。

那些拥有双色墨带的人可以使用红色,以达到最大的强调效果(=粗体斜体)。

tt 下划线

然而,对于非等宽字体来说,效果并不那么显著。

非单声道

右边参差不齐:

右边参差不齐

平均能量损失

\documentclass{book}
\usepackage{xcolor}
\usepackage{soul}
\usepackage{xparse}

\ExplSyntaxOn

    \cs_set:Npn \fc_funcunderline:n #1 {
    % 1=character

\tl_if_blank:eTF
        { #1 }
        {
        \tl_set:Nn \l_tmpc_tl { \c_space_token }
        }
%   else:
    {
        \tl_set:Nn \l_tmpc_tl {
                #1 
                \llap {
                \g_tmpa_tl
                }
        }
    }
    \tl_use:N \l_tmpc_tl    
}

%-------------------- Underliner
\NewDocumentCommand \ull { o m } {
% 1=character to use as marker
% 2=text
                \IfNoValueTF { #1 } 
                        { \tl_gset:Nn \g_tmpa_tl { _ } } 
                        { \tl_gset:Nn \g_tmpa_tl { #1 } }

            \tl_set:Nn \l_tmpa_tl { #2 }

        \group_begin:               
            \ttfamily
            \exp_args:Nx
            \str_map_function:nN 
                    { \l_tmpa_tl }
                    \fc_funcunderline:n
        \group_end:             

}


\ExplSyntaxOff



\begin{document}
\thispagestyle{empty}
\large

How may I do this without the \textit{soul} package?

\colorbox{green!5}{\parbox{\textwidth}{\quad Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}}


\colorbox{red!5}{\vtop{\ul{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}}}

\raggedright
\paragraph{Emphasis}
\ull{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}

\paragraph{Greater Emphasis}
\ull[\raisebox{-1.4ex}{=}]{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}

\paragraph{Greatest Emphasis}
\ull[\raisebox{-1.4ex}{\textcolor{red}{=}}]{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}

\paragraph{Other}
\ull[\raisebox{-1.1ex}{{\tiny x}}]{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}

\end{document}

\llap空格产生以下效果:

空格下划线

平均能量损失

\documentclass{book}
\usepackage{xcolor}
\usepackage{soul}
\usepackage{xparse}

\ExplSyntaxOn

    \cs_set:Npn \fc_funcunderline:n #1 {
    % 1=character

\tl_if_blank:eTF
        { #1 }
        {
        \tl_set:Nn \l_tmpc_tl { \c_space_token              \llap {
                \g_tmpa_tl
                }
}
        }
%   else:
    {
        \tl_set:Nn \l_tmpc_tl {
                #1 
                \llap {
                \g_tmpa_tl
                }
        }
    }
    \tl_use:N \l_tmpc_tl    
}

%-------------------- Underliner
\NewDocumentCommand \ull { o m } {
% 1=character to use as marker
% 2=text
                \IfNoValueTF { #1 } 
                        { \tl_gset:Nn \g_tmpa_tl { _ } } 
                        { \tl_gset:Nn \g_tmpa_tl { #1 } }

            \tl_set:Nn \l_tmpa_tl { #2 }

        \group_begin:               
            \ttfamily
            \exp_args:Nx
            \str_map_function:nN 
                    { \l_tmpa_tl }
                    \fc_funcunderline:n
        \group_end:             

}


\ExplSyntaxOff



\begin{document}
\thispagestyle{empty}
\large

How may I do this without the \textit{soul} package?

\colorbox{green!5}{\parbox{\textwidth}{\quad Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}}


\colorbox{red!5}{\vtop{\ul{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}}}

\raggedright
\paragraph{Emphasis}
\ull{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}

\paragraph{Greater Emphasis}
\ull[\raisebox{-1.4ex}{=}]{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}

\paragraph{Greatest Emphasis}
\ull[\raisebox{-1.4ex}{\textcolor{red}{=}}]{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}

\paragraph{Other}
\ull[\raisebox{-1.1ex}{{\tiny x}}]{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}

\paragraph{rule}
\ull[\raisebox{-1.0ex}{\rule{1.2ex}{1.2pt}}]{Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking; Text underlining with linebreaking;x.}

\end{document}

非等宽:

非单声道


结论:有可能。

比如说,更细一点的规则,稍微高一点,就是可行的方法。

相关内容