1

I have a manuscript I lecture from using class scrbook.

Now for distance teaching I want to redefine some environments (such as proof) so that I get gaps for the proofs on the presentation that I can fill handwritten.

One possibility probably would be to just choose a textcolor of white in these environments. However, then the text remains copy-pasteable on the page. And it might be irritating, if I handwrite over the text, and the invisible characters in the background interfere. Another drawback would be, that if my text contains a \textcolor{red}{redly emphasized} text, it would not vanish:

\documentclass{scrbook}
\usepackage{color}
\usepackage{xcolor}
\usepackage{amsthm,amsfonts,amssymb}

\begin{document} \begin{proof} \textcolor{red}{This} is important \end{proof}

\begin{proof} \color{white} \textcolor{red}{This} is important \end{proof} \end{document}

Numbering should not depend on whether the proofs and their content are hidden or not.

I was wondering, if there were a possibility, to make a font-manipulation, so that instead of the pdf-characters, only empty (and invisible) boxes with the char's size were put into the pdf. That way, numbering would stay intact, and the text were no longer copyable.

thanks, sven

Sven
  • 67
  • 3
    Would \phantom work for you? E.g. https://tex.stackexchange.com/questions/4519/how-do-i-create-an-invisible-character – Willie Wong Sep 15 '20 at 20:44
  • 3
    Generally, people want a larger space for handwriting than the equivalent typeset material. I say this as author of the censor package, where users contact me about similar issues. Thus, how important or not is it that the space allotted exactly equals the equivalent typeset space? – Steven B. Segletes Sep 15 '20 at 20:48
  • @StevenB.Segletes in that case, perhaps a macro that invokes \phantom and changes the font size, so that the amount of space left is potentially bigger, but proportional to the space used in the actual answer? – rbrignall Sep 15 '20 at 20:56
  • 1
    with luatex you can replace the chars: https://tex.stackexchange.com/a/555697/2388 – Ulrike Fischer Sep 15 '20 at 21:04
  • Hi, thanks for the suggestions. Yes \phantom would work, but only for single paragraphs; if the proof environment contains multiple paragraphs, I would need to phantom each paragraph individually instead of redefining the proof environment. Good point about the fontsize, but if my proof-redifinition adds a \large or similar, this would essentially be addressed. So it seems, the luatex-suggestion would be the best way to go for me, if there are no suggestion to get away, without lua:) – Sven Sep 17 '20 at 08:02

1 Answers1

2

You can transform the proofs into invisible text by using the tcolorbox package. In the example below, the background yellow color is stressing the place where the text becomes invisible. enter image description here This is the original document (with the text visible). enter image description here

In the code you find the definition of the box onoffbox that depends on an optional argument; if empty, the text in the box is visible. If non-empty, the text is invisible.

The environment onoffproof is defined using the usual proof and the onoffbox. It inherits the argument of the latter.

\documentclass[11pt, a4paper]{article}
\usepackage{amsmath, amsthm}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\usepackage{ifthen}

\usepackage{lipsum}

\newtheorem{pro}{Proposition}

\newenvironment{onoffbox}[1][]{% \ifthenelse{\equal{#1}{}}{\def\onoff{visible}}{\def\onoff{invisible}} \tcolorbox[% empty, \onoff, parbox=false, noparskip, enhanced, breakable, frame hidden, % default frame hidden boxrule=0pt, % default frame hidden colback=white, % yellow, left=-.5ex, right=-.5ex, before skip=0ex plus 2pt, after skip=1ex plus 2pt] }{\endtcolorbox}

\newenvironment{onoffproof}[1][]{% \begin{onoffbox}[#1]\begin{proof}}{\end{proof}\end{onoffbox}}

\title{Using tcolorbox package for invisible text} \begin{document} \maketitle

\lipsum[1-2]

\begin{pro} $b^2+c^2=a^2$ \end{pro} \begin{onoffproof}[off] It seems that {\color{red}this is an important result}. \lipsum[3-4] This is the end of our test. \end{onoffproof}

\lipsum[5-7] \end{document}

Daniel N
  • 5,687
  • Great, thank you. That is going to just do the job for me. Things I will change: switch on/off based on global bool; leave the words proof/qed visible; increase font-size if hidden; actually, redefine proof to achieve this magic. Thanks again! – Sven Sep 28 '20 at 11:56
  • Hi, the solution worked great until I upgraded to TL2022. With TL2021 the following codeblock inserted into your code above worked: \begin{proof} \begin{onoffproof} %[off] It seems that {\color{red}this is an important result}. \begin{itemize} \item Test within proof \end{itemize} \lipsum[3-4] This is the end of our test. \end{onoffproof} \end{proof} but now it fails with: LaTeX Error: Something's wrong--perhaps a missing \item. pointing to the Line of ¨It seems that ¨ TL2021 is one way out. But generally I would hope this would be doable in TL22. – Sven Oct 21 '22 at 20:03
  • I don't know what TL22 means. Could you say more. – Daniel N Oct 22 '22 at 08:16
  • Sorry, meant to say TeXLive 2022 (with all updates applied). – Sven Oct 22 '22 at 12:28
  • Well, I'm affraid I can't help you with TeXLive. I am an Emacs user. – Daniel N Oct 22 '22 at 13:46
  • Maybe you can. I am using emacs as editor too. My texdistribution is called texlive. I used that only as shorthand for the contained packages. TL21 uses tcolorbox 2020/10/09 version 4.42 and my modified code works with it fine (ok proof within proof is silly, in reality I do something else). Recently I upgraded to TL22 which uses tcolorbox 2022/06/24 version 5.1.1 and the code no longer works:( [of course, other packages are upgraded too and could be the culprit, but the version jump in tcolorbox is large]. Given that the new version breaks the nice suggested code, I hoped for help again. – Sven Oct 22 '22 at 20:44
  • Hi again. On my system, when asking tex --version I get TeX 3.14159265 (TeX Live 2020) kpathsea version 6.3.2 Copyright 2020 D.E. Knuth.. Moreover the code works fine for me. My knowledge concerning TeXLive ends here! It's not too much, I guess. – Daniel N Oct 23 '22 at 14:20
  • Hi, on my system I get tex --version TeX 3.141592653 (TeX Live 2022) kpathsea version 6.3.4... when asking tex --version. So it seems, that the code works no longer in TeX Live 2022, probably due to an upgraded version of tcolorbox. Hence my shortterm workaround (first week of classes), is to downgrade to TL 2021, in which it works; later I will produce a proper mwe and post it. Thank you for your help! – Sven Oct 25 '22 at 15:11
  • Turns out that the option parbox=false makes the difference. If I comment it out, the code works with tcolorbox 5.1.1. To see, whether there is some fix (other than commenting it out), I asked https://tex.stackexchange.com/questions/663638/option-parbox-false-broke-in-itemize-within-tcolorbox-within-proof-between-tcolo . Maybe there is an improvement to tcolorbox. – Sven Oct 31 '22 at 09:36