6

I would like to cross out some words in a presentation and I prefer to have semitransparent lines to facilitate reading.

The MWE hereafter is based on: 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}

The result seems good but, in fact, the part where the lines overlap is (logically) darker than the other parts.

Result of the compilation with a zoom on the crossed out words

Should I modify the code to obtain a cross uniformly colored with an opacity value lower than 1?

Or should I try drawing the cross by another means?

AndréC
  • 24,137
Vince
  • 393

3 Answers3

9

It is enough to draw the cross in a single path instead of two:

\draw[red,draw opacity=0.5, line width=1.5pt] (A.north west) -- (A.south east) (A.south west) -- (A.north east);

screenshot

screenshot-2

\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}
AndréC
  • 24,137
  • 1
    Voting down deserves an explanation. Without explanation this has no meaning other than gratuitous hostility. – AndréC Aug 03 '19 at 06:12
7

You can use the cross out shape node like that:

\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}

enter image description here

frougon
  • 24,283
  • 1
  • 32
  • 55
7

Based on @Hafid Boukhoulda answer, with some simplification (without remember picture option, slightly different node style definition):

\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}

enter image description here

Zarko
  • 296,517