An almost identical question has been asked here, and I am just recycling this answer.
\documentclass{article}
\usepackage[arrows=false]{pagegrid}
\usepackage[margin=0cm,papersize=2cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}
\tikzset{StrikeOut/.style={-,red}}
\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][]{%
\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,#1] (Begin.north) -- (End.south);
\draw[StrikeOut,#1] (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,#1] (Begin.north) -- (Begin.south -| EastLine);
\draw[StrikeOut,#1] (Begin.south) -- (Begin.north -| EastLine);
\draw[StrikeOut,#1] (End.north -| WestLine) -- (End.south);
\draw[StrikeOut,#1] (End.south -| WestLine) -- (End.north);
\else
\draw[StrikeOut,#1] (Begin.south) -- (Begin.north -| EastLine);
\draw[StrikeOut,#1] (Begin.north) -- (Begin.south -| EastLine);
\draw[StrikeOut,#1] (End.north -| WestLine) -- (End.south);
\draw[StrikeOut,#1] (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,#1] ($(Begin.north -| WestLine)+(0,-\X*\LineHeight pt)$) --
($(Begin.south -|EastLine)+(0,-\X*\LineHeight pt)$);
\draw[StrikeOut,#1] ($(Begin.south -| WestLine)+(0,-\X*\LineHeight pt)$) --
($(Begin.north -|EastLine)+(0,-\X*\LineHeight pt)$);
}
\draw[StrikeOut,#1] (Begin.north) -- (Begin.south -| EastLine);
\draw[StrikeOut,#1] (Begin.south) -- (Begin.north -| EastLine);
\draw[StrikeOut,#1] (End.north -| WestLine) -- (End.south);
\draw[StrikeOut,#1] (End.south -| WestLine) -- (End.north);
\fi
\fi
\end{tikzpicture}}
\begin{document}
\noindent
test \StrikeOut{test} \StrikeOut[line width=.5ex]{test}\\
\StrikeOut{test} \StrikeOut[line width=.5ex]{test} test\\
\StrikeOut[line width=.5ex]{test} test \StrikeOut{test}\\
\end{document}
