我想在演示文稿中划掉一些单词,并且我更喜欢使用半透明的线条来方便阅读。
下文中的 MWE 基于: https://tex.stackexchange.com/a/478560/19788
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{tikz}
\newcommand{\txtcross}[1]{%
\tikz[remember picture, baseline=(A.base)]{
\node[inner sep=0pt](A){#1};
}%
\tikz[overlay, remember picture]{
\draw[red, draw opacity=0.5, line width=1.5pt] (A.north west) -- (A.south east);
\draw[red, draw opacity=0.5, line width=1.5pt] (A.south west) -- (A.north east);
}%
}
\begin{document}
Antonio Vivaldi was \mycrossed{an Italian} a Venitian Baroque musical composer, virtuoso violinist, teacher, and priest.
\end{document}
结果看起来不错,但实际上,线条重叠的部分(逻辑上)比其他部分更暗。
我是否应该修改代码以获得均匀着色且不透明度值低于 1 的十字?
或者我应该尝试用其他方法画十字架?
答案1
根据@Hafid Boukhoulda 的回答,进行了一些简化(没有remember picture
选项,节点样式定义略有不同):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\newcommand\mycrossed[1]{\tikz[baseline=(A.base)]
\node[cross out, draw= red, draw opacity=0.5, line width=1.5pt,
inner sep=0pt, outer sep=0pt] (A) {#1};%
}
\begin{document}
Antonio Vivaldi was \mycrossed{an Italian} a Venitian Baroque musical composer, virtuoso violinist, teacher, and priest. Antonio Vivaldi was \mycrossed{an Italian} a Venitian Baroque musical composer, virtuoso violinist, teacher, and priest.
\end{document}
答案2
在一条路径上画十字就足够了,而不需要两条:
\draw[red,draw opacity=0.5, line width=1.5pt] (A.north west) -- (A.south east) (A.south west) -- (A.north east);
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{tikz}
\newcommand{\mycrossed}[1]{%
\tikz[remember picture, baseline=(A.base)]{
\node[inner sep=0pt](A){#1};
}%
\tikz[overlay, remember picture]{
\draw[red,draw opacity=0.5, line width=1.5pt] (A.north west) -- (A.south east) (A.south west) -- (A.north east);
}%
}
\begin{document}
Antonio Vivaldi was \mycrossed{an Italian} a Venitian Baroque musical composer, virtuoso violinist, teacher, and priest.
\end{document}
答案3
您可以cross out
像这样使用形状节点:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\newcommand{\txtcross}[1]{%
\tikz[remember picture, baseline=(A.base)]{
\node[cross out,
draw= red,
line width=1.5pt,
draw opacity=0.5,
inner sep=0pt](A){#1};
}
}
\begin{document}
Jean-Baptiste Lully was \txtcross{a French} an Italian-born French composer, instrumentalist, and dancer
\end{document}