
書式設定されたテキストに下線を付けようとしています。
私がやろうとしていることは次のとおりです。
\usepackage{xcolor}
\usepackage{tikz}
\newcommand{\udensdot}[1]{%
\tikz[baseline=(todotted.base)]{
\node[inner sep=1pt,outer sep=0pt] (todotted) {#1};
\draw[densely dotted] (todotted.south west) -- (todotted.south east);
}%
}%
\newcommand{\ans}[1]{\udensdot{
\textcolor{blue}{\fontfamily{pzc}\selectfont{~#1~}}
}
}
\begin{document}
I go to \ans{the} cinema in \ans{the} evening \ans{eventually}.
\end{document}
次のような結果が得られます。最後の行が他の行より下にあります。
すべての線を同じレベルにして、ディセンダ (ここでは「y」など) が下線と重なるようにしたいのですが、それを実現する方法がわかりません。
助言がありますか?
答え1
この画像のように、テキストフレーズの青い色を黒いドットで覆いたいですか?
そうでない場合でも、ドットをテキスト行のベースライン上に配置して、テキスト フレーズの青色でドットの黒色を覆いたい場合は、 でノードを作成し、\phantom
線を描画してから、 の代わりにテキストでノードを作成できます\phantom
。
\documentclass[border=6pt]{standalone}
\usepackage{xcolor}
\usepackage{tikz}
\newcommand{\udensdot}[1]{%
\tikz[baseline=(todotted.base)]{
\node[inner sep=1pt,outer sep=0pt] (todotted) {\phantom{\mbox{#1}}};
\draw[densely dotted] (todotted.base west) -- (todotted.base east);
\node at (todotted) [inner sep=1pt,outer sep=0pt] {\mbox{#1}};
}%
}
\newcommand{\ans}[1]{\udensdot{%
\textcolor{blue}{\fontfamily{pzc}\selectfont{~#1~}}%
}%
}
\begin{document}
I go to \ans{the} cinema in \ans{the} evening \ans{eventually}.
\end{document}
答え2
TikZ で独自の下線を作成する代わりに、次のようなパッケージを使用できますlua-ul
。
% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{lua-ul}
\usepackage{xcolor}
\usepackage{fontspec}
\newfontfamily{\zapf}{Zapf Chancery}
\makeatletter
\newunderlinetype\beginUnderDot{\cleaders\hb@xt@ .44em{\hss\raisebox{-0.5ex}{.}\hss}}
\makeatother
\NewDocumentCommand\underDot{+m}{{\beginUnderDot#1}}
\newcommand{\ans}[1]{%
{\zapf\underDot{~\textcolor{blue}{#1}~}}%
}
\begin{document}
I go to \ans{the} cinema in \ans{the} evening \ans{eventually}.
\end{document}
またはulem
:
\documentclass{article}
\usepackage[normalem]{ulem}
\usepackage{xcolor}
\newcommand{\ans}[1]{%
{\fontfamily{pzc}\selectfont\dotuline{~\textcolor{blue}{#1}~}}%
}
\begin{document}
I go to \ans{the} cinema in \ans{the} evening \ans{eventually}.
\end{document}
答え3
解決策としては、コマンド でbase west
と を使用することです。base east
\udensdot
\documentclass[border=6pt]{standalone}
\usepackage{xcolor}
\usepackage{tikz}
\newcommand{\udensdot}[1]{%
\tikz[baseline=(todotted.base)]{
\node[inner sep=1pt,outer sep=0pt] (todotted) {#1};
\draw[densely dotted] (todotted.base west) -- (todotted.base east);
}%
}
\newcommand{\ans}[1]{\udensdot{%
\textcolor{blue}{\fontfamily{pzc}\selectfont{~#1~}}%
}%
}
\begin{document}
I go to \ans{the} cinema in \ans{the} evening \ans{eventually}.
\end{document}