Skip to content

Instantly share code, notes, and snippets.

@maxanier
Last active June 10, 2022 08:45
Show Gist options
  • Save maxanier/c63f9b5dede1ecda6cf9b0e346ec413d to your computer and use it in GitHub Desktop.
Save maxanier/c63f9b5dede1ecda6cf9b0e346ec413d to your computer and use it in GitHub Desktop.
Latex package - Convenient toggle-able censoring of information for double-blind review e.g. for IEEEtran class
% doubleblind - @maxanier https://gist.github.com/maxanier/c63f9b5dede1ecda6cf9b0e346ec413d
% Convenient toggle-able censoring of information for double-blind review e.g. for IEEEtran class
% Supports linebreaks in text
%
% Include as
% \usepackage[]{doubleblind}
% and add `anonym` option to enable censoring:
% \usepackage[anonym]{doubleblind}
%
% Provides the following commands:
% \anonymize{}
% Reliably removes the contained content and replaces it with blank space if anonym is enabled
% \includegraphicsanonym[options]{image1}{image2}
% Includes the first image when anonym is enabled, and the second one otherwise
%
% If loaded it modifies the following commands to automatically censor the content:
% \thanks
% \IEEEauthorblockN
% \IEEEauthorblockA
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{doubleblind}[2022/06/10 Simple anonymization for double blind review]
% Use soulutf8 to allow unicode characters like ä
\RequirePackage{soulutf8}
%Define if condition identifier with default value
\newif\if@anonymize
\@anonymizefalse
% Package options
\DeclareOption{anonym}{\@anonymizetrue}
\DeclareOption*{\PackageWarning{doubleblind}{Unknown ‘\CurrentOption’}}
\ProcessOptions\relax
% Provide anonymization commands - Basic functionality based on https://tex.stackexchange.com/a/26303/272094
\if@anonymize
\DeclareRobustCommand*\anonymize{%
\SOUL@setup%
\def\SOUL@everytoken{\phantom{\the\SOUL@token}}%
\def\SOUL@everyhyphen{%
\discretionary{%
\SOUL@setkern\SOUL@hyphkern%
\phantom{\SOUL@sethyphenchar}%
}{}{}%
}%
\def\SOUL@everyexhyphen##1{%
\SOUL@setkern\SOUL@hyphkern%
\hbox{\phantom{##1}}%
\discretionary{}{}{%
\SOUL@setkern\SOUL@charkern%
}%
}%
\SOUL@%
}
\newcommand{\includegraphicsanonym}[3][]{\includegraphics[#1]{#2}}
\else
\newcommand{\anonymize}[1]{#1}
\newcommand{\includegraphicsanonym}[3][]{\includegraphics[#1]{#3}}
\fi
% Overwrite IEEEtran commands
\ifdefined\thanks
\NewCommandCopy{\IEEEtranthanks}{\thanks}
\renewcommand{\thanks}[1]{\IEEEtranthanks{\anonymize{#1}}}
\fi
\ifdefined\IEEEauthorblockN
\NewCommandCopy{\IEEtranIEEEauthorblockN}{\IEEEauthorblockN}
\renewcommand{\IEEEauthorblockN}[1]{\IEEtranIEEEauthorblockN{\anonymize{#1}}}
\fi
\ifdefined\IEEEauthorblockA
\NewCommandCopy{\IEEtranIEEEauthorblockA}{\IEEEauthorblockA}
\renewcommand{\IEEEauthorblockA}[1]{\IEEtranIEEEauthorblockA{\anonymize{#1}}}
\fi
@maxanier
Copy link
Author

Include with

%\usepackage[anonym]{doubleblind} %To enable censorship
\usepackage[]{doubleblind}

\thanks
\IEEEauthorblockN
\IEEEauthorblockA

To use alternative images (if the original e.g. contains logos):

\includegraphicsanonym[width=0.4\textwidth]{cencored.jpg}{original.jpg}

To censor alternative content:
\anonymize{lorem ipsum}

Unlike \phantom line breaks are supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment