在 \seqsplit 的单词中插入空格

在 \seqsplit 的单词中插入空格
\documentclass{article}
\usepackage{tabularx,seqsplit}
\begin{document}

\begin{table}[h!]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
    \begin{tabularx}{\textwidth}{|c |c |c |X |X |X |}
    \hline
    1 & 2 & 3 & 
         \seqsplit{Testing 1 testing 2 Testing 3l} & 
         \seqsplit{Testing 1 testing 2 Testing 3} & 
         \seqsplit{Testing 1 testing 2 Testing 3} \\
         \hline
    1 & 2 & 3 & & & \\
    1 & 2 & 3 & & & \\
    \hline
    \end{tabularx}
\caption{tes}
\label{tab:my_label}
\end{table}

\end{document}

结果: 在此处输入图片描述

这些话应该是

Testing 1 testing 2 Testing 3

但结果却是

Testing1testing2Testing3

答案1

您可以先用“隐式空格”替换空格,然后\hspace{0pt}在每个项目后添加映射标记列表。

\documentclass{article}
\usepackage{tabularx}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\spliteverywhere}{m}
 {
  \tl_set:Nn \l__spliteverywhere_tl { #1 }
  \tl_replace_all:Nnn \l__spliteverywhere_tl { ~ } { \c_space_tl }
  \tl_map_function:NN \l__spliteverywhere_tl \__spliteverywhere:n
 }
\tl_new:N \l__spliteverywhere_tl
\cs_new:Nn \__spliteverywhere:n { #1 \hspace{0pt} }
\ExplSyntaxOff

\begin{document}

\begin{table}[h!]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
    \begin{tabularx}{\textwidth}{|c |c |c |X |X |X |}
    \hline
    1 & 2 & 3 & 
         \spliteverywhere{Testing 1 testingtesting 2 Testing 3l} & 
         \spliteverywhere{Testing 1 testing 2 Testing 3} & 
         \spliteverywhere{Testing 1 testing 2 Testing 3} \\
         \hline
    1 & 2 & 3 & & & \\
    1 & 2 & 3 & & & \\
    \hline
    \end{tabularx}
\caption{test}
\label{tab:my_label}
\end{table}

\end{document}

在此处输入图片描述

答案2

seqsplit用于打破计算机代码等中的字母序列,对于自然语言文本,最好使用 TeX 的正常换行符:

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx}
\begin{document}

\begin{table}[htp]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
    \begin{tabularx}{\textwidth}{|c |c |c |X |X |X |}
    \hline
    1 & 2 & 3 & 
         Testing 1 testing 2 Testing 3l & 
         Testing 1 testing 2 Testing 3 & 
         Testing 1 testing 2 Testing 3 \\
         \hline
    1 & 2 & 3 & & & \\
    1 & 2 & 3 & & & \\
    \hline
    \end{tabularx}
\caption{tes}
\label{tab:my_label}
\end{table}

\end{document}

相关内容