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
.