3

I need a crossed out word in Latex like here:

How to cross out a word in LaTex

But I need to rotate my cross 45 degrees. Whenever I add a rotate=45, I also rotate my word, which is not what I want:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{rotating}

\newcommand*{\mycancel}[2][draw]{%
\begin{tikzpicture}
  \node[cross out,rotate=45,inner sep=0pt,outer sep=0pt, #1]{#2};
\end{tikzpicture}
}


\begin{document}

\mycancel{A}

\end{document}

Good cross, bad letter

Rotate doesn't help:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{rotating}

\newcommand*{\mycancel}[2][draw]{%
\begin{tikzpicture}
  \node[cross out,rotate=45,inner sep=0pt,outer sep=0pt, #1]{#2};
\end{tikzpicture}
}


\begin{document}

\mycancel{\begin{rotate}{315}A\end{rotate}}


\end{document}

Good letter, unreadable cross

user56153
  • 999

2 Answers2

3

Here remove the tikzpicture enviroment and add another node for the actual cross-out. Then add \tikz[baseline=(one.base)]{...} to set the proper baseline.

Output

enter image description here

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}

\newcommand{\mycancel}[3][]{%
\tikz[baseline=(one.base)]{
  \node[draw=none, inner sep=0,outer sep=0, #1] (one) at (0,0) {#2};
  \node[draw,cross out, inner sep=0, outer sep=0, rotate=#3, #1, minimum size=.2cm] at (one) {\phantom{#2}};
}
}

\begin{document}
Hello, there this is an \mycancel{A}{0}
\mycancel{\huge A}{15}
\mycancel{\Large A}{262}
\mycancel{\footnotesize A}{150} 
\end{document}
Alenanno
  • 37,338
  • I have adapted this solution this way, because I only need a 45 degrees rotation: \newcommand{\mycancel}[2][]{% \tikz[baseline=(one.base)]{ \node[draw=none, inner sep=0,outer sep=0, #1] (one) {#2}; \node[draw,cross out, thick, outer sep=0, rotate=45, #1] at (one) {}; } } – user56153 Jun 13 '15 at 17:17
  • @user56153 Sure! :) – Alenanno Jun 13 '15 at 17:20
1

A simple \draw command is probably an easier way:

\documentclass{article}

\usepackage{tikz}

\newcommand*{\mycancel}[2][]{%
  \begin{tikzpicture}[inner sep=0pt, baseline=(X.base)]
    \node (X) {#2};
    \draw[#1] (X.west) -- (X.east) (X.south) -- (X.north);
  \end{tikzpicture}%
}

\begin{document}
  \mycancel{A}\qquad\mycancel[red, thick]{hello world}\qquad\mycancel{g}
\end{document}

Result

Heiko Oberdiek
  • 271,626