使用 flowfram 审查文本

使用 flowfram 审查文本

我在使用审查包创建黑色文本时遇到了问题,我只是想能够有效地从 laTex 创建的 PDF 中涂黑一些单词。

停电文本

“停电”文本与蓝色文本颜色相同。 - 很好。

首先,正如您在第二行看到的,“遮罩”矩形的高度比它应该的高度短得多,因为它意味着掩盖与上面一行相同的文本。

其次,电话号码和电子邮件地址不会被屏蔽。不知道为什么。我以为这可能是由于空格(就电话号码而言)造成的,但正如您从 latex 中看到的那样,我已经涵盖了这两种情况。

% document class
\documentclass[a4paper,11pt,final]{memoir}

%set pdf to print transparency properly
\pdfminorversion 7

% stuff
\pagestyle{empty} % no page numbering
\setlength{\parindent}{0pt}     % no paragraph indentation

% required packages (add your own)
\usepackage{flowfram}                   % column layout
\usepackage[top=1cm,left=1cm,right=1cm,bottom=1cm]{geometry}% margins
\usepackage{graphicx}                   % figures
\usepackage{hyperref}           % hyper links
\usepackage[svgnames]{xcolor} % Call colours by their svgnames
\usepackage[UKenglish]{babel} % English language/hyphenation
\usepackage[none]{hyphenat} % no hyphenation
\usepackage{censor} % blackout text

% Create column layout
% define length commands
\setlength{\vcolumnsep}{\baselineskip}
\setlength{\columnsep}{\vcolumnsep}

% define custom colours
\definecolor{OceanBlue}{RGB}{37,133,208}
\definecolor{BlueGrey}{RGB}{91,126,153}

% get rid of ugle hyperref boxes
\hypersetup{
  colorlinks   = true, %Colours links instead of ugly boxes
  urlcolor     = black, %Colour for external hyperlinks
  linkcolor    = black, %Colour of internal links
  citecolor   = red %Colour of citations
}

% define macros for spacer
\newcommand{\SmallSep}{\vspace{0.5em}}
\newcommand{\BigSep}{\vspace{1em}}

% KEYWORD IDENTIFIERS:
\def\Missile{\censor*{7}}
\def\Size{\censor*{2}}
\def\`password'{\censor*{7}}
\def\someone@something{\censor*{7}}
\def\01234567890{\censor*{7}}
\def\01234 567 890{\censor*{7}}

\begin{document}

\fontsize{26}{26}
\color{OceanBlue}
\usefont{OT1}{phv}{b}{n}

\begin{center}

the Missile silo\\
the {\Missile} silo\\

\fontsize{11}{13}
\usefont{OT1}{phv}{m}{n}

\usefont{OT1}{phv}{b}{n}%bold
Telephone: 
\usefont{OT1}{phv}{m}{n}%normal
01234 567 890\\
\usefont{OT1}{phv}{b}{n}%bold
Telephone: 
\usefont{OT1}{phv}{m}{n}%normal
01234567890\\

\usefont{OT1}{phv}{b}{n}%bold
E-Mail:
\usefont{OT1}{phv}{m}{n}%normal
\href{mailto:mailto:[email protected]}{[email protected]}\\
\SmallSep

\href{https://vimeo.com}{https://vimeo.com}
\color{BlueGrey}
password: {\`password'}\\
\color{Black}

%end centre alignment
\end{center}
\end{document}

答案1

编辑

我认为这确实是一个伪错误审查包。根据手册,审查线的默认高度是应该2.1ex。因此,对于较大的字体,审查线的行高应该更大,而实际上,审查线的高度始终相同。问题是censor.sty定义\censorruleheight为长度,然后将其设置为等于2.1ex。与\censorruleheight长度一样,当将其设置为等于时,它2.1ex会立即转换为9.90062pt,此后审查线始终具有此固定高度。更好的选择是让包\censorruleheight用扩展为 的宏替换2.1ex。事实上,如果我们添加行

\def\censorruleheight{2.1ex}

到你的 MWE 然后我们得到期望的结果:

在此处输入图片描述

对于您的其他问题,您示例中的电子邮件地址和电话号码未受审查的原因是您没有要求这样做:您需要用 包围它们\censor{...},或者像您对 所做的那样用宏替换它们\Missile。您确实定义了宏

\def\01234567890{\censor*{7}}
\def\01234 567 890{\censor*{7}}

但是它们有两个问题。首先,您实际上不会在文档的后面使用它们。然而,更重要的是,tex 不喜欢在宏名称中使用数字或空格,因此如果您尝试使用这些,它们将不起作用。例如

\def\HomePhone{\censor*{7}}
\def\WorkPhone{\censor*{7}}

会更好。对于上面的图片,我只是\censor{...}在电话号码周围使用了。

完整代码如下:

% document class
\documentclass[a4paper,11pt,final]{memoir}

%set pdf to print transparency properly
\pdfminorversion 7

% stuff
\pagestyle{empty} % no page numbering
\setlength{\parindent}{0pt}     % no paragraph indentation

% required packages (add your own)
\usepackage{flowfram}                   % column layout
\usepackage[top=1cm,left=1cm,right=1cm,bottom=1cm]{geometry}% margins
\usepackage{graphicx}                   % figures
\usepackage{hyperref}           % hyper links
\usepackage[svgnames]{xcolor} % Call colours by their svgnames
\usepackage[UKenglish]{babel} % English language/hyphenation
\usepackage[none]{hyphenat} % no hyphenation
\usepackage{censor} % blackout text

% Create column layout
% define length commands
\setlength{\vcolumnsep}{\baselineskip}
\setlength{\columnsep}{\vcolumnsep}

% define custom colours
\definecolor{OceanBlue}{RGB}{37,133,208}
\definecolor{BlueGrey}{RGB}{91,126,153}

% get rid of ugle hyperref boxes
\hypersetup{
colorlinks   = true, %Colours links instead of ugly boxes
urlcolor     = black, %Colour for external hyperlinks
linkcolor    = black, %Colour of internal links
citecolor   = red %Colour of citations
}

% define macros for spacer
\newcommand{\SmallSep}{\vspace{0.5em}}
\newcommand{\BigSep}{\vspace{1em}}

% KEYWORD IDENTIFIERS:
\def\Missile{\censor{Missile}}
\def\Size{\censor*{2}}
\def\`password'{\censor*{7}}%      bad macro name - DON'T use!
\def\someone@something{\censor*{7}}
\def\01234567890{\censor*{7}}%     bad macro name - DON'T use!
\def\01234 567 890{\censor*{7}}%   bad macro name - DON'T use!

\def\censorruleheight{2.1ex}% to fix bug in censor.sty

\begin{document}

\fontsize{26}{26}
\color{OceanBlue}
\usefont{OT1}{phv}{b}{n}

\begin{center}

the Missile silo\\
the {\Missile} silo\\

\fontsize{11}{13}
\usefont{OT1}{phv}{m}{n}

\usefont{OT1}{phv}{b}{n}%bold
Telephone:
\usefont{OT1}{phv}{m}{n}%normal
01234 567 890\\
\usefont{OT1}{phv}{b}{n}%bold
Telephone:
\usefont{OT1}{phv}{m}{n}%normal
\censor{01234567890}\\

\usefont{OT1}{phv}{b}{n}%bold
E-Mail:
\usefont{OT1}{phv}{m}{n}%normal
\censor{\href{mailto:mailto:[email protected]}{[email protected]}}\\
\SmallSep

\href{https://vimeo.com}{https://vimeo.com}
\color{BlueGrey}
password: {\`password'}\\
\color{Black}

%end centre alignment
\end{center}
\end{document}

相关内容