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?

1
  • 1
    You need a transparency group. Just google of look on this site - it is simple. Aug 2, 2019 at 20:21

3 Answers 3

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

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}
1
  • 1
    Voting down deserves an explanation. Without explanation this has no meaning other than gratuitous hostility.
    – AndréC
    Aug 3, 2019 at 6: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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.