2

I would like to ask about boxed text and underline within the gb4e environment. I would like to box the text to indicate that this word is important. At the same time, I would like to draw an underline from the boxed text to the end of the sentence, which is emphasized with boldface.

I would like to this within the gb4e environment because the text boxed and underlined is not English. However, as you can see, the gloss is not properly assigned to the underlined text. Also, there is a space between the box and the underline as in (2) in the picture in the bottom of this post.

What I would like to make is the attached one, which is created by MS Word.

enter image description here

Could you tell me how to write the code for this type of expression?

The following is the code I wrote.

\documentclass{article}
\usepackage{times}
\usepackage[utf8]{inputenc}
\usepackage[margin=2cm]{geometry}
\usepackage{gb4e} 
\noautomath


\begin{document}
\begin{exe}
\ex[]{\gll Naoya-wa Mari-ga Nani-o Non-da ka Yumi-ni it-ta no? \\
      Naoya-\textsc{Top} Mari-\textsc{Nom} what-\textsc{Acc} drink-\textsc{Past} Q Yumi-\textsc{Dat} it-\textsc{Past} Q?  \\
      \trans `(Lit.) For which $x$, $x$ a thing, Naoya said to Yumi whether Mari drink $x$.'  
}

\ex[]{\gll Naoya-wa Mari-ga \underline{\framebox{\textbf{Nani}}-o Non-da ka Yumi-ni it-ta \textbf{no}}? \\
      Naoya-\textsc{Top} Mari-\textsc{Nom} what-\textsc{Acc} drink-\textsc{Past} Q Yumi-\textsc{Dat} it-\textsc{Past} Q?  \\
      \trans `(Lit.) For which $x$, $x$ a thing, Naoya said to Yumi whether Mari drink $x$.'  
}

\ex[]{\gll Naoya-wa Mari-ga \underline{\textbf{Nani}-o Non-da ka Yumi-ni it-ta \textbf{no}}? \\
      Naoya-\textsc{Top} Mari-\textsc{Nom} what-\textsc{Acc} drink-\textsc{Past} Q Yumi-\textsc{Dat} it-\textsc{Past} Q?  \\
      \trans `(Lit.) For which $x$, $x$ a thing, Naoya said to Yumi whether Mari drink $x$.'  
}

\ex[]{\gll Naoya-wa Mari-ga \framebox{\textbf{Nani}}-o Non-da ka Yumi-ni it-ta \textbf{no}? \\
      Naoya-\textsc{Top} Mari-\textsc{Nom} what-\textsc{Acc} drink-\textsc{Past} Q Yumi-\textsc{Dat} it-\textsc{Past} Q?  \\
      \trans `(Lit.) For which $x$, $x$ a thing, Naoya said to Yumi whether Mari drink $x$.'  
}

\end{exe}
\end{document}

The following is the result of the code.

enter image description here

3

Because of the way the glossing is done each individual word/gloss pair in the gloss lines must be separated. This is why you can't use \underline around groups of words: the entire underlined group will be considered a single word for the glossing macro, which is not what you want.

Here's a solution using TikZ. I've defined two commands \UL and \LU to denote the beginning and end of the underlining. Then I've made a \gluline command which underlines everything between those two markers. This can be used with or without the \framebox.

Some things to understand about this solution:

  • you need to compile the document twice to get the underlining to show up
  • if the \UL ... \LU words break over a line, the underlining will fail.

If you need underlining to work across broken lines of the gloss, you will need to mark subsequent stretches of underlining manually, (i.e., not using the wrapper macros). I've added an example to show how to do this.

\documentclass{article}
%\usepackage{times} % don't use this use newtxtext instead
\usepackage{newtxtext}
\usepackage[utf8]{inputenc}
\usepackage[margin=2cm]{geometry}
\usepackage{tikz}
\newcommand*{\tkzmk}[1]{\tikz[remember picture,overlay] \node (#1) {};}
\newcommand*{\tkzuline}[2]{\tikz[overlay,remember picture]{ \draw (#1.south) -- (#2.south);}}
\newcommand*{\UL}{\tkzmk{1}}
\newcommand*{\LU}{\tkzmk{2}}
\newcommand*{\gluline}{\tkzuline{1}{2}}
\usepackage{gb4e} 
\noautomath



\begin{document}
\begin{exe}

\ex[]{\gll Naoya-wa Mari-ga \UL\framebox{\textbf{Nani}}-o Non-da ka Yumi-ni it-ta \textbf{no}\LU? \\
      Naoya-\textsc{Top} Mari-\textsc{Nom} what-\textsc{Acc} drink-\textsc{Past} Q Yumi-\textsc{Dat} it-\textsc{Past} Q?  \\
      \trans `(Lit.) For which $x$, $x$ a thing, Naoya said to Yumi whether Mari drink $x$.' } 
\gluline



\ex[]{\gll Naoya-wa Mari-ga \UL\textbf{Nani}-o Non-da ka Yumi-ni it-ta \textbf{no}\LU? \\
      Naoya-\textsc{Top} Mari-\textsc{Nom} what-\textsc{Acc} drink-\textsc{Past} Q Yumi-\textsc{Dat} it-\textsc{Past} Q?  \\
      \trans `(Lit.) For which $x$, $x$ a thing, Naoya said to Yumi whether Mari drink $x$.'  
}
\gluline


\end{exe}
\begin{minipage}{.5\linewidth}
\begin{exe}
\ex[]{\gll Naoya-wa Mari-ga \UL\framebox{\textbf{Nani}}-o Non-da ka\LU{} \tkzmk{3}Yumi-ni it-ta \textbf{no}\tkzmk{4}? \\
      Naoya-\textsc{Top} Mari-\textsc{Nom} what-\textsc{Acc} drink-\textsc{Past} Q Yumi-\textsc{Dat} it-\textsc{Past} Q?  \\
      \trans `(Lit.) For which $x$, $x$ a thing, Naoya said to Yumi whether Mari drink $x$.' } 
\gluline
\tkzuline{3}{4}
\end{exe}
\end{minipage}
\end{document}

output of code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.