空格划线,使其忽略下括号下面的内容

空格划线,使其忽略下括号下面的内容

我正在尝试将单词分解为词素,并以简洁的方式显示它们。

\usepackage{amsmath}

% ... etc ...

d. not compound, polymorphemic:
$\underbrace{\text{doubt}}_{\text{free root}}\: - \:\underbrace{\text{less}}_{\text{free derivational suffix}}\: - \:\underbrace{\text{ly}}_{\text{bound derivational suffix}}$

我已使下括号正常工作,但是它们之间的破折号看起来有点杂乱,因为它们考虑了下括号下方内容的宽度,该内容通常但并不总是大于其上方的内容。我如何以某种方式强制破折号出现在下括号上方内容的中央,而忽略其下方的所有内容?在下图中,less和之间的破折号看起来在右边,但和ly之间的破折号太靠左了,因为下面的内容比下面的内容小。doubtlessdoubtless

结果

期望结果:

欲望

答案1

\textminus如果你愿意做一些测量,你可以毫无问题地在元素之间设置破折号(如下)。\tmpbox用于存储整个构造没有破折号、\tmplenA\tmplenB分别\tmplenC用于测量第一、第二和第三个“术语”的底部和下括号文本之间的最宽元素。

在此处输入图片描述

\documentclass{article}

\usepackage{mathtools}

\newsavebox{\tmpbox}
\newlength{\tmplenA}
\newlength{\tmplenB}
\newlength{\tmplenC}

\begin{document}

d. not compound, polymorphemic:
\[
  % Capture width of entire structure
  \savebox{\tmpbox}{$
    \underbrace{\text{doubt\strut}}_{\text{free root}}
    \quad% \hspace{1em}
    \underbrace{\text{less\strut}}_{\text{free derivational suffix}}
    \quad% \hspace{1em}
    \underbrace{\text{ly\strut}}_{\text{bound derivational suffix}}
  $}
  % Set entire structure in a zero-width, left-aligned box
  \makebox[0pt][l]{\usebox{\tmpbox}}
  \settowidth{\tmplenA}{\text{\scriptsize free root}}% Widest element of first "term"
  \settowidth{\tmplenB}{\text{\scriptsize free derivational suffix}}% Widest element of second "term"
  \settowidth{\tmplenC}{\text{\scriptsize bound derivational suffix}}% Widest element of third "term"
  % Set box of width matching original structure (left-aligned)
  \makebox[\wd\tmpbox][l]{%
    \hspace{0.5\tmplenA}% Skip to middle of first "term"
    \makebox[\dimexpr0.5\tmplenA+1em+0.5\tmplenB]{\textminus}% Set \textminus halfway between first and second "term"
    \makebox[\dimexpr0.5\tmplenB+1em+0.5\tmplenC]{\textminus}% Set \textminus halfway between second and third "term"
  }
\]

\end{document}

答案2

您需要测量各部分(顶部和底部)并在项目之间打印破折号,其偏移量取决于左侧和右侧项目的宽度。这里我使用零宽度框,因此不会增加空间;项目之间的间隔为一个 em,因此短破折号非常适合。

\documentclass{article}
\usepackage{amstext}

\NewDocumentCommand{\textubrace}{mm}{%
  \ensuremath{\underbrace{\text{#1\strut}}_{\text{#2\vphantom{ly}}}}%
}

\ExplSyntaxOn

\NewDocumentCommand{\morphemes}{m}
 {% #1 = {doubt}{free root},{less}{free derivational suffix},{ly}{bound derivational suffix}
  \naiveai_morphemes:n { #1 }
 }

\seq_new:N \l__naive_morphemes_items_seq % the items
\seq_new:N \l__naive_morphemes_top_seq % the widths of the top items
\seq_new:N \l__naive_morphemes_bot_seq % the widths of the bottom items

\dim_new:N \l__naive_morphemes_tmp_dim

\cs_new_protected:Nn \naiveai_morphemes:n
 {
  \seq_set_from_clist:Nn \l__naive_morphemes_items_seq { #1 }
  \seq_clear:N \l__naive_morphemes_top_seq
  \seq_clear:N \l__naive_morphemes_bot_seq
  % store the half-widths
  \seq_map_function:NN \l__naive_morphemes_items_seq \__naiveai_morphemes_measure:n
  % check that the bottom widths aren't less than the corresponding top width
  \seq_map_indexed_inline:Nn \l__naive_morphemes_top_seq
   {
    \dim_compare:nT { \seq_item:Nn \l__naive_morphemes_bot_seq { ##1 } < ##2 }
     {
      \seq_set_item:Nnn \l__naive_morphemes_bot_seq { ##1 } { ##2 }
     }
   }
  % typeset
  \int_step_inline:nn { \seq_count:N \l__naive_morphemes_items_seq - 1 }
   {
    % the item
    \exp_last_unbraced:Ne \textubrace { \seq_item:Nn \l__naive_morphemes_items_seq { ##1 } }
    % half space
    \nobreak
    \skip_horizontal:n { 0.5em }
    % the dash; first compute the offset
    \dim_set:Nn \l__naive_morphemes_tmp_dim
     {
      (
       \seq_item:Nn \l__naive_morphemes_bot_seq { ##1 } % left bot width
       -
       \seq_item:Nn \l__naive_morphemes_top_seq { ##1 } % left top width
      )
      -
      (
       \seq_item:Nn \l__naive_morphemes_bot_seq { ##1 + 1 } % right bot width
       -
       \seq_item:Nn \l__naive_morphemes_top_seq { ##1 + 1 } % right top width
      )
     }
    % the dash, suitably offset 
    \hbox_to_zero:n
     {
      \hss
      \dim_compare:nTF { \l__naive_morphemes_tmp_dim > 0pt }
       { -- \skip_horizontal:n { \l__naive_morphemes_tmp_dim } }
       { \skip_horizontal:n { -\l__naive_morphemes_tmp_dim } -- } 
      \hss
     }
    % half space
    \nobreak
    \skip_horizontal:n { 0.5em }
   }
  % the last item
  \exp_last_unbraced:Ne \textubrace { \seq_item:Nn \l__naive_morphemes_items_seq { -1 } }
 }
\cs_new_protected:Nn \__naiveai_morphemes_measure:n
 {
  \__naiveai_morphemes_measure_both:nn #1
 }

\cs_new_protected:Nn \__naiveai_morphemes_measure_both:nn
 {
  \hbox_set:Nn \l_tmpa_box { #1 }
  \seq_put_right:Nx \l__naive_morphemes_top_seq { \dim_eval:n { (\box_wd:N \l_tmpa_box)/2 } }
  \hbox_set:Nn \l_tmpa_box { \ensuremath { \scriptstyle \text { #2 } } }
  \seq_put_right:Nx \l__naive_morphemes_bot_seq { \dim_eval:n { (\box_wd:N \l_tmpa_box)/2 } }
 }

\ExplSyntaxOff

\begin{document}

\begin{center}
\morphemes{
  {doubt}{free root},
  {less}{free derivational suffix},
  {ly}{bound derivational suffix}
}
\\[2ex]
\morphemes{
  {xxxxxxx}{x},
  {abc}{abcde},
  {yyyyy}{yyyyyyy}
}
\end{center}

\end{document}

在此处输入图片描述

相关内容