2

Chinese words aren't separated by spaces. As a result, neighboring underlines will be joined together. The xeCJK package provides a CJKunderline- command, but the underline it generates is unsymmetrical (the left end is often too short) and not directly customizable.

An alternative solution was provided in an old Chinese post. The underline looks nice, but unfortunately interferes with line breaking:

\documentclass[a4paper, 10pt]{article}

\usepackage{xcolor, indentfirst}
\usepackage[
  left=3.2cm, right=3.2cm,
  top=3.8cm, bottom=3.8cm,
]{geometry}

\usepackage[quiet]{fontspec}
\usepackage{xeCJK}
\setCJKmainfont{SimSun}

\setlength{\parindent}{2em}
\renewcommand{\baselinestretch}{1.3}

\usepackage[normalem]{ulem}

% How to make \myuline not mess with line breaking?
\newcommand{\basiculine}{\bgroup\markoverwith{\textcolor{gray}{\rule[-0.32em]{1pt}{0.54pt}}}\ULon}
\newcommand{\myuline}[1]{\hskip0.1em\basiculine{\kern-0.1em\hbox{#1\kern-0.1em}}\hskip0.1em}

\begin{document}

进得诏便行。\myuline{主簿}\myuline{陈琳}谏曰:“太后此诏,必是十常侍之谋,切不可去。去必有祸,\myuline{不骗你呀}。”进曰:“\myuline{太后}\myuline{诏我},有何祸事?”

\end{document}

Underline pushes punctuation marks away.

The first line's last underline pushes punctuation marks to the beginning of the next line. I'm not at all familiar with TeX constructs. How to improve this, please?

3

TeX is always allowed to break a line at an \hskip, unless explicitly told not to:

\documentclass[a4paper, 10pt]{article}

\usepackage{xcolor, indentfirst}
\usepackage[
  left=3.2cm, right=3.2cm,
  top=3.8cm, bottom=3.8cm,
]{geometry}

\usepackage[quiet]{fontspec}
\usepackage{xeCJK}
\setCJKmainfont{SimSun}

\setlength{\parindent}{2em}
\renewcommand{\baselinestretch}{1.3}

\usepackage[normalem]{ulem}

% How to make \myuline not mess with line breaking?
\newcommand{\basiculine}{%
  \bgroup\markoverwith{\textcolor{gray}{\rule[-0.32em]{1pt}{0.54pt}}}\ULon
}
\newcommand{\myuline}[1]{%
  \hspace{0.1em}%
  \basiculine{\kern-0.1em\hbox{#1\kern-0.1em}}%
  \nobreak % <----- no line break before the space
  \hspace{0.1em}%
}

\begin{document}

进得诏便行。\myuline{主簿}\myuline{陈琳}谏曰:“太后此诏,必是十常侍之谋,切不可去。去必有祸,\myuline{不骗你呀}。”进曰:“\myuline{太后}\myuline{诏我},有何祸事?”

\end{document}

enter image description here

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.