How to trim a certain part of each character in a whole document?

enter image description here

\documentclass[preview,border=12pt,varwidth]{standalone}
\usepackage{lipsum,color}

\begin{document}

\lipsum[1]


\vspace{-\dimexpr\parskip+\baselineskip}
\edef\NN{\the\prevgraf}
\noindent\begin{picture}(0,0)
\multiput(0,0)(0,12){12}{\textcolor{white}{\rule[-2pt]{\linewidth}{5pt}}}
\end{picture}
\end{document}

Of course there is a minimal solution in ConTeXt.

\definebar
  [chop]
  [overstrike]
  [offset=.4,
   rulethickness=1.5,
   color=white]

\starttext

\chop{\WORDS{\input lorem }}

\stoptext

enter image description here


A TikZ solution (quickly modified version of a TikZ based multiline underline). It doesn't work across multiple pages and if the line distance is more than \baselineskip. This reuses ideas from https://tex.stackexchange.com/a/411361/117050 and https://tex.stackexchange.com/a/411655/117050.

\documentclass[]{article}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}
\usepackage{refcount}

\tikzset{tikzCUT/.style={line width=1.1ex,white}}
\makeatletter
\newcommand{\gettikzxy}[3]{% from https://tex.stackexchange.com/a/58590/121799
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \xdef#2{\the\pgf@x}%
  \xdef#3{\the\pgf@y}%
}
\newlength\tikzCUT@length
\newcount\tikzCUT@count
\newcommand*{\tikzCUT}[1][0ex]{%
  \if\relax\detokenize{#1}\relax
    \tikzCUT@length=0ex\relax
  \else
    \tikzCUT@length=#1\relax
  \fi
  \tikzCUT@}
\newcounter{tikzCUTCounter}
\newcommand{\tikzCUT@}[2][-0.1ex]{%
  \tikz[remember picture,overlay, baseline=(Begin.base)]{%
    \node[anchor=base,inner sep=0pt,outer sep=0pt,xshift=-\tikzCUT@length]
      (Begin) {\strut};
    \gettikzxy{($(Begin.base)-(current page.south west)$)}
      {\tikzCUT@bx}{\tikzCUT@by}%
  }%
  \stepcounter{tikzCUTCounter}%
  \tikzCUT@label{begin}%
  #2%
  \tikzCUT@label{end}%
  \expandafter\tikzCUT@pagecheck\expandafter{\the\c@tikzCUTCounter}%
  \tikz[remember picture,overlay, baseline=(End.base)]{%
    \node[anchor=base,inner sep=0pt,outer sep=0pt,xshift=+\tikzCUT@length]
      (End) {\strut};%
    \gettikzxy{($(End.base)-(current page.south west)$)}
      {\tikzCUT@ex}{\tikzCUT@ey}%
  }%
  \begin{tikzpicture}[overlay,remember picture]
    \ifdim\dimexpr\tikzCUT@ey-\tikzCUT@by = 0pt
      % one line
      \draw[tikzCUT] ($(Begin.base)+(0,#1)$) -- ($(End.base)+(0,#1)$);%
    \else
      % multiple lines
      \draw
        ($(current page text area.west)-(\tikzCUT@length,0)$) node(WestLine){};
      \draw
        ($(current page text area.east)+(\tikzCUT@length,0)$) node(EastLine){};
      \tikzCUT@drawBtoE{#1}
      \ifdim\dimexpr\tikzCUT@by-\tikzCUT@ey>\baselineskip
        % more than two lines
        \bgroup
        \tikzCUT@drawMultipleLines{#1}{\baselineskip}
        \egroup
      \fi
    \fi
  \end{tikzpicture}}
\newcommand*\tikzCUT@label[1]{%
  \null
  \@bsphack
  \protected@write\@auxout{}{%
    \string\newlabel{tikzCUT:#1:\arabic{tikzCUTCounter}}
      {{\@currentlabel}{\arabic{page}}}}%
  \@esphack}
\newcommand*\tikzCUT@pagecheck[1]{%
  \typeout{\pageref{tikzCUT:begin:#1}}%
  \typeout{\pageref{tikzCUT:end:#1}}%
  \ifnum\getpagerefnumber{tikzCUT:begin:#1}=%
    \getpagerefnumber{tikzCUT:end:#1}\relax
  \else
    \GenericError{Multi-page warning}{AHHHH}{}%
  \fi}
\newcommand*\tikzCUT@drawMultipleLines[2]{%
  \tikzCUT@length=#2
  \tikzCUT@count=1
  \loop\ifdim\dimexpr\tikzCUT@by-\tikzCUT@count\tikzCUT@length>\tikzCUT@ey
  \draw[tikzCUT]
    ($(Begin.base -| WestLine)+(0,#1)-(0,\tikzCUT@count\tikzCUT@length)$)--
    ($(Begin.base -| EastLine)+(0,#1)-(0,\tikzCUT@count\tikzCUT@length)$);
  \advance\tikzCUT@count by 1
  \repeat}
\newcommand*\tikzCUT@drawBtoE[1]{%
  \draw[tikzCUT]
    ($(Begin.base)+(0,#1)$) -- ($(Begin.base -| EastLine)+(0,#1)$)
    ($(End.base)+(0,#1)$) -- ($(End.base -| WestLine)+(0,#1)$);}
\makeatother

\begin{document}
\tikzCUT{this foo away}
\end{document}

enter image description here

Tags:

Programming