%20se%20superpongan%20a%20la%20l%C3%ADnea.png)
Estoy intentando subrayar un texto formateado.
Lo que estoy intentando hacer es lo siguiente:
\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}
Obtengo el siguiente resultado, donde la última línea está debajo de las demás:
Me gustaría que todas las líneas estuvieran al mismo nivel y que los descendentes (como "y" aquí) se superpongan al subrayado, pero no sé cómo lograrlo.
¿Alguna sugerencia?
Respuesta1
¿Quieres que puntos negros cubran el color azul de la frase textual como en esta imagen?:
Si no, pero desea que los puntos estén en la línea base de la línea de texto y que el color azul de la frase textual cubra el color negro de los puntos, puede crear un nodo con a \phantom
, dibujar la línea y luego crear un nodo. con texto en lugar de \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}
Respuesta2
En lugar de crear tu propio subrayado en TikZ, puedes usar un paquete como 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}
O 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}
Respuesta3
Una solución es usar base west
y base east
en el comando \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}