在表格中同时使用下划线和删除线

在表格中同时使用下划线和删除线

我是 LaTeX 的新手,目前正在使用它来尝试整理一份关于亚美尼亚语正字法的报告。我正在尝试创建一个表格,其中一列将显示打印的字母,另一列将显示它们在“手写”字体中的样子。在第二列中,我想放置一条基线和一条中线来显示字母的书写方式。我的代码看起来类似于此示例(其中我已将实际字体替换为 Times New Roman):

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage[normalem]{ulem}
\usepackage{color}

\newcommand\baseline{\bgroup\markoverwith{\textcolor{blue}{\rule[0ex]{2pt}{0.4pt}}}\ULon}
\newcommand\midline{\bgroup\markoverwith{\textcolor{red}{\rule[0.72ex]{2pt}{0.4pt}}}\ULon}
\newcommand\textline[1]{\huge{\baseline{\midline{\makebox[1cm][c]{#1}}}}}

\begin{document}
\begin{tabular}[c]{|c|c|c|c|}
\hline
A & \textline{A} & B & \textline{B}\\
\hline
C & \textline{C} & D & \textline{D}\\
\hline
\end{tabular}
\end{document}

我正在使用 TeXstudio 和 XeLaTeX。输出似乎没问题,但我感到疑惑的是这个不断弹出的错误,即:

! Dimension too large.
\UL@on ...UL@height \advance \UL@height -\ULdepth 
                                              \setbox \UL@box \hbox {{#1...
l.15 A & \textline{A}
                  & B & \textline{B}\\
I can't work with sizes bigger than about 19 feet.
Continue and I'll use the largest value I can.

正如我所说,它似乎编译正确,但我想知道这个错误的原因是什么,以及是否有任何可能的补救措施。非常感谢!

答案1

我会采取不同的方法并且不会尝试用下划线做任何花哨的事情。

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{xcolor}

\newcommand{\drebaserule}{\rlap{\color{blue}\rule{1cm}{0.4pt}}}
\newcommand{\dremidrule}{\rlap{\color{red}\rule[0.72ex]{1cm}{0.4pt}}}
\newcommand{\dredemo}[1]{\huge\drebaserule\dremidrule\makebox[1cm]{#1}}

\begin{document}
\begin{tabular}[c]{|c|c|c|c|}
\hline
A & \dredemo{A} & B & \dredemo{B}\\
\hline
C & \dredemo{C} & D & \dredemo{D}\\
\hline
\end{tabular}
\end{document}

我制作的盒子宽度为零,但线条长度适当。

如果您想要虚线规则,那么您可以dashrule按如下方式使用该包:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{xcolor}
\usepackage{dashrule}

\newlength{\dresampletextwd}
\setlength{\dresampletextwd}{1cm}
\newcommand{\dremidrule}{\rlap{\color{red}\hdashrule[0.72ex][x]{\dimexpr\dresampletextwd+2pt}{0.4pt}{3pt 2pt}}}
\newcommand{\drebaserule}{\rlap{\color{blue}\hdashrule[0pt][c]{\dresampletextwd}{0.4pt}{}}}
\newcommand{\dredemo}[1]{\huge\drebaserule\dremidrule\makebox[\dresampletextwd]{#1}}

\begin{document}
\begin{tabular}[c]{|c|c|c|c|}
\hline
A & \dredemo{A} & B & \dredemo{B}\\
\hline
C & \dredemo{C} & D & \dredemo{D}\\
\hline
\end{tabular}
\end{document}

在此处输入图片描述

在这里我添加了长度,以便更容易进入并更改包含示例文本的框的宽度。

相关内容