将所有空格替换为连字符

将所有空格替换为连字符

法律文件中使用连字符而不是空格是一种很好的做法,这样任何人都不能在签署合同后添加任何内容。

例如

------------------------------------------
------------Contract----------------------
------------------------------------------
The-parties-of-this-contract-agree-to-----
lorem-ipsum-dolor-sit-amet----------------
------------------------------------------

如果没有 verbatim 包,可以在 LaTeX 中实现这个吗?

答案1

这可能与一切不兼容,但是......

在此处输入图片描述

\documentclass{article}



\def\space{\leavevmode\leaders\hrule\hskip 0.5em plus .2em minus .2em\kern0pt }
{\obeyspaces\global\let =\space}
\def\center{%
\parindent0pt %
\everypar{\hrulefill}%
\def\par{\hrulefill\endgraf}%
\obeylines\obeyspaces
}
\def\endcenter{\par}

\def\flushleft{%
\parindent0pt %
\def\par{\hrulefill\endgraf}%
\obeylines\obeyspaces
}
\def\endflushleft{\par}



\begin{document}


\begin{center}
Contract
\end{center}
\begin{flushleft}
The parties of this contract agree to     
lorem ipsum dolor sit amet
\end{flushleft}                                         

\end{document}

答案2

这是使用该SOUL包的一个选项。它似乎对基本输入来说工作得相当好。由于SOUL命令不能嵌套,它(据我所知)需要一个单独的宏来居中(\midl)和删除空格(\strikespace)。大多数字体命令应该可以做到这一点,但如果你遇到一个破坏一切的宏,你可以尝试用 soul “注册”它,就像我对\fbox:参见SOUL 文档了解进一步细节以及其他可能的症结所在。与往常一样,实施可能会得到改进,是的,这也可能与几乎所有东西都不兼容。

在此处输入图片描述

代码:

\documentclass{article}
\usepackage{xparse}
\usepackage{soul}

\parindent0pt
\soulregister{\fbox}{1}
\makeatletter

\DeclareRobustCommand*\strikespaceaux{
\SOUL@ulsetup
\SOUL@stpreamble
\def\SOUL@everyspace##1{%
  ##1%
  \SOUL@ulleaders
  \hskip\spaceskip
  \null
}
\def\SOUL@everysyllable{%
  \the\SOUL@syllable
  \SOUL@setkern\SOUL@charkern
}
\def\SOUL@postamble{%
    \fillit
}
\SOUL@
}

\DeclareRobustCommand*\midlaux{
\def\SOUL@preamble{%
    \dimen@\SOUL@ulthickness
    \dimen@i=-.5ex
    \advance\[email protected]\dimen@
    \edef\SOUL@uldepth{\the\dimen@i}%
        \let\SOUL@ulcolor\SOUL@stcolor
        \SOUL@uldp=\SOUL@uldepth
    \SOUL@ulht=-\SOUL@uldp
    \advance\SOUL@uldp\SOUL@ulthickness
    \spaceskip\SOUL@spaceskip
        \noindent\fillit}
\def\SOUL@everyspace##1{%
  ##1%
  \SOUL@ulleaders
  \hskip\spaceskip
  \null
}
\def\SOUL@everysyllable{%
  \the\SOUL@syllable
  \SOUL@setkern\SOUL@charkern
}
\def\SOUL@postamble{%
    \fillit
}
\SOUL@
}

\def\fillit{\noindent\leaders\hrule\@depth\SOUL@uldp\@height\SOUL@ulht\hfill\kern\z@}

\makeatother

\ExplSyntaxOn

\NewDocumentCommand {\strikespace}
    {>{ \SplitList {\par}} +m}
    {\tl_map_inline:nn {#1} {\strikespaceaux{##1}\par}}

\NewDocumentCommand{\midl}
    {>{ \SplitList {\par}} +m}
    {\tl_map_inline:nn {#1} {\midlaux{##1}\par}}

\ExplSyntaxOff

\begin{document}
\midl{\fbox{\large A title}}
\midl{\textbf{ Below you will find two paragraphs}\par \textbf{of lorem ipsum}\par}

\strikespace{
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras interdum, massa sit amet convallis vehicula, diam quam commodo lorem, placerat vehicula nulla lacus eu quam. Nunc et nulla libero, in bibendum felis. Nulla rutrum hendrerit nulla ac fringilla. In ultrices rutrum leo, non gravida elit porttitor eu. Quisque suscipit sapien a nunc tristique at blandit eros sagittis. Suspendisse potenti. Nulla enim nisi, pellentesque a suscipit nec, condimentum vel lacus. Mauris a elementum justo. Integer fermentum tempor ligula, ut ullamcorper nunc pretium ac.

Sed tempus mattis elit, nec faucibus nisl sagittis id. Nulla at neque libero. Donec fringilla, felis nec commodo porta, nibh quam mollis augue, et interdum lectus lectus ut ipsum. Donec ac tortor velit, quis mollis arcu. In dapibus laoreet accumsan. Nullam sed purus orci, ac porttitor velit. Pellentesque auctor nisl at odio pharetra mattis. Vestibulum purus ante, lacinia sit amet aliquet eleifend, blandit eget risus. Phasellus et erat augue, a commodo risus. Vestibulum semper enim in neque semper malesuada ut a magna. Praesent tellus odio, blandit ut interdum eu, tincidunt ac leo.
}

\end{document}

相关内容