-2

Good morning, I'm trying to avoid informations from my CV. In particular, I'd like to have a method to substitute my personal address with a black box of the same size of the text. I'm currently using \phantom , and I'd like to know whether there exists a way to have a black space instead of a blank space.

  • 1
    Welcome. // Next time please try preparing a simple piece of code, which a) compiles once we copied it, b) shows your problem, c) discarded all unnecessary parts. This usually improves answers considerably. Thank you – MS-SPO Jul 17 '23 at 12:11

4 Answers4

5

Here is a better way to do it:

result

This is what you get, after copy and paste from the pdf:

To censor it .
To blackout it, .

For more alternatives see topic security at ctan, where only luacensor may be of interest.

\documentclass[10pt, a4paper]{article}
\usepackage{censor}

\begin{document}

To censor it \censor{censor it}.\

To blackout it, \blackout{black it out}.

\end{document}

MS-SPO
  • 11,519
3

Something like that

\newlength{\myboxw}
\newlength{\myboxh}
\newcommand{\blackphantom}[1]%
{\settowidth{\myboxw}{#1}%
\settoheight{\myboxh}{#1}%
\rule{\myboxw}{\myboxh}}

\blackphantom{Hidden Text}

would work, but only horizontally (i.e. does not support multi-lines content or text with wrapping/hyphenation). (I think \phantom has the same behavior, though...)

3

Here's a way to do it:

  • use packages xcolor and soul to highlight text via \hl{}
  • it visually overwrites it

However, if you'd mark, copy and paste the black part into an editor, you still can read it: strike-out.

result

\documentclass[10pt, a4paper]{article}
\usepackage{xcolor, soul}

\begin{document}

1: Whatever you want to \hl{highlight}.\

\sethlcolor{black} 2: Whatever you want to strike-\hl{out}.\

3: Whatever you want to \hl{highlight}.\% uses current color

\sethlcolor{yellow}% switch "back" 4: Whatever you want to \hl{highlight}.

\end{document}

P.S.: This may still be an option, as not all users of pdf files even know, less try, they can mark and copy text selections ...

MS-SPO
  • 11,519
2

A typesetting-based solution using Lua code can be used to define a custom Open Type font feature which, when switched on for a font, allows the font to replace one glyph (set) with another (set), including ligatures.

censor1

And:

censor2

The more traditional "censor's ink block":

censor3

Requires LuaLaTeX.

MWE

\documentclass{article}
\usepackage{fontspec}
\usepackage{lipsum}

\newcommand\anycxchar{uniEBA3} \newcommand\anycxcharb{uni2580} \newcommand\anycxcharc{circlecopyrt}

\directlua { luaotfload.add_colorscheme("cxscheme", { ["FF200080"] = {"\anycxchar"}, }) }

\directlua { luaotfload.add_colorscheme("cyscheme", { ["FF20A090"] = {"\anycxcharb"}, }) }

\directlua { luaotfload.add_colorscheme("czscheme", { ["FF0000"] = {"T_h"}, }) }

\directlua{ fonts.handlers.otf.addfeature { name = "anycx", type = "substitution", data = { ["a"] = "\anycxchar", ["b"] = "\anycxchar", ["c"] = "\anycxchar", ["d"] = "\anycxchar", ["e"] = "\anycxchar", ["f"] = "\anycxchar", ["g"] = "\anycxchar", ["h"] = "\anycxchar", ["i"] = "\anycxchar", ["j"] = "\anycxchar", ["k"] = "\anycxchar", ["l"] = "\anycxchar", ["m"] = "\anycxchar", ["n"] = "\anycxchar", ["o"] = "\anycxchar", ["p"] = "\anycxchar", ["q"] = "\anycxchar", ["r"] = "\anycxchar", ["s"] = "\anycxchar", ["t"] = "\anycxchar", ["u"] = "\anycxchar", ["v"] = "\anycxchar", ["w"] = "\anycxchar", ["x"] = "\anycxchar", ["y"] = "\anycxchar", ["z"] = "\anycxchar", ["0"] = "\anycxchar", ["1"] = "\anycxchar", ["2"] = "\anycxchar", ["3"] = "\anycxchar", ["4"] = "\anycxchar", ["5"] = "\anycxchar", ["6"] = "\anycxchar", ["7"] = "\anycxchar", ["8"] = "\anycxchar", ["9"] = "\anycxchar", ["r"] = "\anycxchar", [","] = "\anycxchar", ["."] = "\anycxchar", ["/"] = "\anycxchar", ["<"] = "\anycxchar", [">"] = "\anycxchar", ["?"] = "\anycxchar", } } }

\directlua{ fonts.handlers.otf.addfeature { name = "anycy", type = "substitution", data = { ["hyphen"] = "\anycxcharb", ["a"] = "\anycxcharb", ["b"] = "\anycxcharb", ["c"] = "\anycxcharb", ["d"] = "\anycxcharb", ["e"] = "\anycxcharb", ["f"] = "\anycxcharb", ["g"] = "\anycxcharb", ["h"] = "\anycxcharb", ["i"] = "\anycxcharb", ["j"] = "\anycxcharb", ["k"] = "\anycxcharb", ["l"] = "\anycxcharb", ["m"] = "\anycxcharb", ["n"] = "\anycxcharb", ["o"] = "\anycxcharb", ["p"] = "\anycxcharb", ["q"] = "\anycxcharb", ["r"] = "\anycxcharb", ["s"] = "\anycxcharb", ["t"] = "\anycxcharb", ["u"] = "\anycxcharb", ["v"] = "\anycxcharb", ["w"] = "\anycxcharb", ["x"] = "\anycxcharb", ["y"] = "\anycxcharb", ["z"] = "\anycxcharb", ["0"] = "\anycxcharb", ["1"] = "\anycxcharb", ["2"] = "\anycxcharb", ["3"] = "\anycxcharb", ["4"] = "\anycxcharb", ["5"] = "\anycxcharb", ["6"] = "\anycxcharb", ["7"] = "\anycxcharb", ["8"] = "\anycxcharb", ["9"] = "\anycxcharb", [32] = "\anycxcharb", ["r"] = "\anycxcharb", [","] = "\anycxcharb", ["."] = "\anycxcharb", ["/"] = "\anycxcharb", ["<"] = "\anycxcharb", [">"] = "\anycxcharb", ["?"] = "\anycxcharb", } } }

\directlua{ fonts.handlers.otf.addfeature { name = "anycz2", type = "substitution", data = { ["T_h"] = "\anycxcharc", } }}

\directlua{ fonts.handlers.otf.addfeature { name = "anycz", type = "substitution", data = { ["hyphen"] = "\anycxcharc", ["a"] = "\anycxcharc", ["b"] = "\anycxcharc", ["c"] = "\anycxcharc", ["d"] = "\anycxcharc", ["e"] = "\anycxcharc", ["f"] = "\anycxcharc", ["g"] = "\anycxcharc", ["h"] = "\anycxcharc", ["i"] = "\anycxcharc", ["j"] = "\anycxcharc", ["k"] = "\anycxcharc", ["l"] = "\anycxcharc", ["m"] = "\anycxcharc", ["n"] = "\anycxcharc", ["o"] = "\anycxcharc", ["p"] = "\anycxcharc", ["q"] = "\anycxcharc", ["r"] = "\anycxcharc", ["s"] = "\anycxcharc", ["t"] = "\anycxcharc", ["u"] = "\anycxcharc", ["v"] = "\anycxcharc", ["w"] = "\anycxcharc", ["x"] = "\anycxcharc", ["y"] = "\anycxcharc", ["z"] = "\anycxcharc", ["0"] = "\anycxcharc", ["1"] = "\anycxcharc", ["2"] = "\anycxcharc", ["3"] = "\anycxcharc", ["4"] = "\anycxcharc", ["5"] = "\anycxcharc", ["6"] = "\anycxcharc", ["7"] = "\anycxcharc", ["8"] = "\anycxcharc", ["9"] = "\anycxcharc", [32] = "\anycxcharc", ["r"] = "\anycxcharc", [","] = "\anycxcharc", ["."] = "\anycxcharc", ["/"] = "\anycxcharc", ["<"] = "\anycxcharc", [">"] = "\anycxcharc", ["?"] = "\anycxcharc", } } }

\newfontfamily\fany{Clara}[ RawFeature=+anycx, Colour=cxscheme, ]

\newfontfamily\fancy{FiraMath}[ RawFeature=+anycy, Colour=cyscheme, ]

\newfontfamily\fancz{AntykwaTorunska}[ RawFeature=+anycz, ]

\newfontfamily\fancza{AntykwaTorunska}[ Ligatures=TeX, Colour=czscheme, ]

\newfontfamily\fanczb{AntykwaTorunska}[ RawFeature=+anycz;+anycz2, ]

\begin{document}

abcde fghij klmnop qrstu wxyz 1234567890 ,./<>?

\fany

abcde fghij klmnop qrstu wxyz 1234567890 ,./<>?

\lipsum

\newpage \fancy

abcde fghij klmnop qrstu wxyz 1234567890 ,./<>?

\lipsum

\newpage \normalfont Q: What is the question to $1+1=1$?

A: {\fancz The cat sat on the mat.}

\fancza ``Th'' is a ligature: \fanczb The cat sat on the mat.

\end{document}

Cicada
  • 10,129