我想在斜体文本中用不同的颜色给连续的句子加下划线。到目前为止,我已经尝试了该soul
包并且可以更改下划线属性。但是,我在更改斜体文本中连续句子的下划线颜色时遇到了困难。
考虑以下情况:我希望每个\ul
都有不同的颜色。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{color,soul}
\begin{document}
\setul{0.5ex}{0.3ex}
\definecolor{Green}{rgb}{0,1,0}
\setulcolor{Green}
\setul{0.5ex}{0.3ex}
\definecolor{Red}{rgb}{1,0.0,0.0}
\setulcolor{Red}
\setul{0.5ex}{0.3ex}
\definecolor{Blue}{rgb}{0,0.0,1}
\setulcolor{Blue}
\Large
\textit{
Ham followed now ecstatic use speaking exercise may repeated.
\ul{Himself he evident oh greatly my on inhabit general concern}.
\ul{It earnest amongst he showing females so improve in picture.
Mrs can hundred its greater account}.
\ul{Distrusts daughters certainly suspected convinced our
perpetual him yet.} Words did noise taken right state are since.
}
\end{document}
这是我想要的输出:
答案1
\ul
与使用设置u
下划线类似l
,您也可以使用\setulcolor{<colour>}
之内 \textit
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{color,soul}
\setul{0.5ex}{0.3ex}
\setulcolor{blue}
\begin{document}
\Large
\textit{
Ham followed now ecstatic use speaking exercise may repeated.
\ul{Himself he evident oh greatly my on inhabit general concern}.
\setulcolor{red}
\ul{It earnest amongst he showing females so improve in picture.
Mrs can hundred its greater account}.
\setulcolor{green}
\ul{Distrusts daughters certainly suspected convinced our
perpetual him yet.} Words did noise taken right state are since.
}
\end{document}
答案2
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{soul}
\usepackage[dvipsnames]{xcolor} % for expanded colour set
\setul{0.5ex}{0.3ex}
\newcommand{\ulcolor}[2][Red]{\setulcolor{#1}\ul{#2}}
%opening
\title{Underlining in several colours}
\author{LaTex Dude}
\begin{document}
\Large
\textit{
Ham followed now ecstatic use speaking exercise may repeated.
\ulcolor[Blue]{Himself he evident oh greatly my on inhabit general concern}.
\ulcolor{It earnest amongst he showing females so improve in picture.
Mrs can hundred its greater account}.
\ulcolor[Green]{Distrusts daughters certainly suspected convinced our
perpetual him yet.} Words did noise taken right state are since.
}
I would like to underline this \ulcolor{in red} and this \ulcolor[Blue]{in blue} and this \ulcolor[Green]{in green}.
\end{document}