使文字不可見

使文字不可見

我有一份使用課堂抄本講課的手稿。

現在,對於遠距教學,我想重新定義一些環境(例如證明),以便我可以手寫地填補簡報上的證明空白。

一種可能性可能是在這些環境中僅選擇白色文字顏色。但是,文字仍然可以在頁面上複製貼上。如果我在文字上手寫,並且背景中的不可見字元會幹擾,這可能會令人惱火。另一個缺點是,如果我的文本包含文本\textcolor{red}{redly emphasized},它不會消失:

\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}

編號不應取決於證據及其內容是否隱藏。

我想知道是否有可能進行字體操作,以便只將具有字元大小的空(且不可見)框放入pdf中,而不是pdf字元。這樣,編號將保持完整,並且文字不再可複製。

謝謝,斯文

答案1

您可以使用該tcolorbox套件將校樣轉換為不可見文字。在下面的範例中,黃色背景強調了文字不可見的位置。 在此輸入影像描述 這是原始文檔(文字可見)。 在此輸入影像描述

在程式碼中,您可以找到onoffbox依賴可選參數的框的定義;如果為空,則框中的文字可見。如果非空,則文字不可見。

環境onoffproof是使用通常的proofonoffbox.它繼承了後者的論點。

\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}

相關內容