Как поставить крестик над словом?

Как поставить крестик над словом?

Мне интересно, существует ли в LaTeX команда, с помощью которой можно поставить крестик над словом?

решение1

С помощью TikZ (и shapesбиблиотеки) можно создавать красивые эффекты перечеркивания.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes}

\newcommand{\crossme}[2][]{%


\tikz[baseline=(X.base)]{\node [outer sep=0pt,cross out,draw=#1,line width=2pt] (X) {#2};}%
}


\begin{document}
A nice \crossme[blue]{crossed} word.
\end{document}

введите описание изображения здесь

решение2

Для полноты картины: \xcancelиз cancelпакета тоже работает.

\documentclass{beamer}
\usepackage{cancel}
\begin{document}
\begin{frame}
\frametitle{Crossing out words}
\begin{overlayarea}{\textwidth}{\textheight}
No more \xcancel{alcohol}. No more
\textcolor{red}{\xcancel{\textcolor{black}{fast food}}}.
\end{overlayarea}
\end{frame}
\end{document}

введите описание изображения здесь

ОБНОВЛЯТЬ: Просто ради забавы: версия, которая работает с переносами строк (но не с переносами страниц!) и не вводит дополнительных пробелов. Основано наэтот ответ.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}
\usepackage{ulem}
\newcommand\HighLight{\bgroup\markoverwith{\textcolor{yellow}{\rule[-.5ex]{.1pt}{2.5ex}}}\ULon}

\tikzset{StrikeOut/.style={thick,-}}


\makeatletter
\newcommand{\gettikzxy}[3]{% from https://tex.stackexchange.com/a/58590/121799
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \global\edef#2{\the\pgf@x}%
  \global\edef#3{\the\pgf@y}%
}
\makeatother
\newcommand{\StrikeOut}[2][2pt]{%
\tikz[remember picture,overlay, baseline=(Begin.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (Begin) {\strut};}#2%
\tikz[remember picture,overlay, baseline=(End.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (End) {\strut};}%
\begin{tikzpicture}[overlay,remember picture]
\gettikzxy{($(Begin.north)-(current page.south west)$)}{\BeginxN}{\BeginyN}
\gettikzxy{($(End.north)-(current page.south west)$)}{\EndxN}{\EndyN}%\typeout{\BeginyN\space\EndyN}
\pgfmathtruncatemacro{\mytest}{\EndyN-\BeginyN}
\ifnum\mytest=0\relax% begin and and in the same line %\typeout{begin and end in the same line}
\draw[StrikeOut] (Begin.north) -- (End.south);
\draw[StrikeOut] (Begin.south) -- (End.north);
\else% \typeout{end below begin}
\path (current page text area.north west) -- (current page text area.south west)
node(WestLine)[left]{};
\path (current page text area.north east) -- (current page text area.south east)
node(EastLine)[right]{};
\gettikzxy{($(End.north)-(current page.south west)$)}{\EndxN}{\EndyN}
\gettikzxy{($(Begin.south)-(current page.south west)$)}{\BeginxS}{\BeginyS}
\pgfmathtruncatemacro{\mytest}{\BeginyS-\EndyN+1pt}% \typeout{\mytest}
\ifnum\mytest<2\relax% \typeout{end in the next line after begin}%
\pgfmathtruncatemacro{\mytest}{\BeginxS-\EndxN}% \typeout{\mytest}
\ifnum\mytest>0\relax
\draw[StrikeOut] (Begin.north) -- (Begin.south -| EastLine);
\draw[StrikeOut] (Begin.south) -- (Begin.north -| EastLine);
\draw[StrikeOut] (End.north -| WestLine) -- (End.south);
\draw[StrikeOut] (End.south -| WestLine) -- (End.north);
\else
\draw[StrikeOut] (Begin.south) -- (Begin.north -| EastLine);
\draw[StrikeOut] (Begin.north) -- (Begin.south -| EastLine);
\draw[StrikeOut] (End.north -| WestLine) -- (End.south);
\draw[StrikeOut] (End.south -| WestLine) -- (End.north);
\fi
\else
\pgfmathsetmacro{\LineHeight}{\the\baselineskip}
\pgfmathtruncatemacro{\NumLines}{-1+(\BeginyN-\EndyN)/\LineHeight}
\typeout{\NumLines}
\foreach \X in {1,...,\NumLines}
{
\draw[StrikeOut] ($(Begin.north -| WestLine)+(0,-\X*\LineHeight pt)$) -- 
($(Begin.south -|EastLine)+(0,-\X*\LineHeight pt)$);
\draw[StrikeOut] ($(Begin.south -| WestLine)+(0,-\X*\LineHeight pt)$) -- 
($(Begin.north -|EastLine)+(0,-\X*\LineHeight pt)$);
}
\draw[StrikeOut] (Begin.north) -- (Begin.south -| EastLine);
\draw[StrikeOut] (Begin.south) -- (Begin.north -| EastLine);
\draw[StrikeOut] (End.north -| WestLine) -- (End.south);
\draw[StrikeOut] (End.south -| WestLine) -- (End.north);
\fi
\fi
\end{tikzpicture}}
\begin{document}
\begin{frame}
\frametitle{Striking out several lines}
\begin{overlayarea}{\textwidth}{\textheight}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. \StrikeOut{Sed a leo ut
erat luctus scelerisque. Suspendisse auctor mauris sit amet fringilla
hendrerit.} Maecenas eu tortor eu diam fringilla scelerisque sit amet eget enim.
Nam vitae bibendum erat, sit amet scelerisque felis. \StrikeOut{Suspendisse placerat
vitae velit pharetra lobortis et marmottae.} Donec ut erat a erat porta aliquet. Nulla eget
augue sem. Proin orci neque, eleifend id eleifend id, venenatis sit amet diam.
\StrikeOut{Mauris lacus est, cursus eget sapien at, pharetra lobortis ante. Proin
tempus ipsum tellus, ut ultricies magna congue nec. Vestibulum ante ipsum primis
in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse potenti.
In posuere dapibus urna, vitae euismod magna iaculis at.} Pellentesque pretium,
lorem ut vehicula egestas, velit dolor porta nunc, id interdum ipsum purus vel
dolor.
\end{overlayarea}
\end{frame}

\begin{frame}
\frametitle{Striking out several lines (no strike out)}
\begin{overlayarea}{\textwidth}{\textheight}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a leo ut
erat luctus scelerisque. Suspendisse auctor mauris sit amet fringilla
hendrerit. Maecenas eu tortor eu diam fringilla scelerisque sit amet eget enim.
Nam vitae bibendum erat, sit amet scelerisque felis. Suspendisse placerat
vitae velit pharetra lobortis et marmottae. Donec ut erat a erat porta aliquet. Nulla eget
augue sem. Proin orci neque, eleifend id eleifend id, venenatis sit amet diam.
Mauris lacus est, cursus eget sapien at, pharetra lobortis ante. Proin
tempus ipsum tellus, ut ultricies magna congue nec. Vestibulum ante ipsum primis
in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse potenti.
In posuere dapibus urna, vitae euismod magna iaculis at. Pellentesque pretium,
lorem ut vehicula egestas, velit dolor porta nunc, id interdum ipsum purus vel
dolor.
\end{overlayarea}
\end{frame}
\end{document}

введите описание изображения здесь

Свойства линии можно настроить, отрегулировав StrikeOut.

Связанный контент