8

Got inspired from a nice article titled "why All Caps is so hard to read", I want to produce the following result for my document.

enter image description here

MWE

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

\begin{document}
\lipsum[1]
\end{document}

Question

How to do this automatically?

enter image description here

In order to be flexible, let r be the ratio of height to remove (relative to the baseline).

Bonus: How to convert all characters to capital before trimming?

  • I think that, for it to be "automatic", you would actually need to create a truncated font. – Steven B. Segletes Feb 27 '18 at 18:57
  • @StevenB.Segletes or you could "stack" a box over the text.... – David Carlisle Feb 27 '18 at 19:56
  • @DavidCarlisle Don't think the thought hadn't crossed my mind ;^). – Steven B. Segletes Feb 27 '18 at 19:58
  • Sadly both soul and ulem don't work out of the box, as those apparently put the line behind the text. – Skillmon likes topanswers.xyz Feb 27 '18 at 22:00
4

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

| improve this answer | |
5

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}
| improve this answer | |
  • @ArtificialStupidity if it was normal text you could use \MakeUppercase but \lipsum isn't expandable so doesn't work there. – David Carlisle Feb 27 '18 at 20:17
  • your example used standalone so I rather assumed you only wanted single page but yes this just overprints lines going up from the end of the paragraph so if there is a page break mid paragraph it would need more work. You don't really want this for extended runs of multi-page text do you??? – David Carlisle Feb 27 '18 at 20:26
  • adding rules at a fixed distance to every page over the text is easy (just add a picture mode to the page foot that adds lines as here) if you want multi-page version with arbitrary text such as section headings etc and having to recalculate where the rules go for each text block it's possible but far too much work for the answer here sorry. Hopefully one of the answers here will get you started so you can fill out to whatever full version you need. @ArtificialStupidity – David Carlisle Feb 27 '18 at 20:31
2

Here is another proposal based on TikZ and lineno. You only need to adjust \TruncateRatio to get a different truncation ratio r. If you want to truncate only a portion of your text, put it bewtween \begin{runninglinenumbers} and \end{runninglinenumbers} (and comment out \linenumbers). David Carlisle's comments on \MakeUppercase apply here, too. The reason why I post this (given the other excellent answers) is that it is trivial to play with opacity and, perhaps more importantly, also works with equations.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\tikznode}[2]{%
\tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};%
}%from https://tex.stackexchange.com/questions/402462/tikz-equivalent-of-pstricks-commands-ncbar-and-rnode/402466#402466

\usepackage{lineno}
\usepackage{lipsum}
\newcommand{\TruncateRatio}{0.5}
\renewcommand\makeLineNumber
        {\tikznode{left}{\strut}\ \rlap{\hskip\textwidth\ \tikznode{right}{\strut}}
        \tikz[overlay,remember picture]{\fill[white](left.south)rectangle($(right.south)!\TruncateRatio!(right.north)$);}}
\begin{document}
\linenumbers
\lipsum[1]
     \begin{linenomath*}
       \begin{eqnarray*}
         b_1 &=& a_{11}x_1 + a_{12}x_2 \\
         b_2 &=& a_{21}x_1 + a_{22}x_2
       \end{eqnarray*}
     \end{linenomath*}
\lipsum[2]
\end{document}

enter image description here

| improve this answer | |
  • Much better than my 1min adaptation! – Skillmon likes topanswers.xyz Feb 28 '18 at 7:35
  • But you shouldn't use eqnarray anymore! – Skillmon likes topanswers.xyz Feb 28 '18 at 7:36
  • @Skillmon Thanks! But I just copied the equation literally from the lineno manual. Seems like the authors didn't want to blow up their manual by loading additional packages, and I have the same reservation here. Needless to say that my propsal also works with align , but of course for fractions it will just kill the denominator. In any case, there are also no instructions from the OP how to deal with equations, I guess that you will always find a pathological case with subscripts and so on. – user121799 Feb 28 '18 at 16:05
2

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.