Skip to content

Instantly share code, notes, and snippets.

@maxanier
Last active April 4, 2026 08:21
Show Gist options
  • Select an option

  • Save maxanier/c63f9b5dede1ecda6cf9b0e346ec413d to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
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.

@hackathi
Copy link
Copy Markdown

hackathi commented Apr 7, 2025

Using this as is with the latest IEEEtran.sty gave me an error upon processing \maketitle. Apparently, something doesn't like this being pseudo-empty, so I fixed it to say "anonymous" instead:

\ifdefined\IEEEauthorblockN
\NewCommandCopy{\IEEtranIEEEauthorblockN}{\IEEEauthorblockN}
\renewcommand{\IEEEauthorblockN}[1]{\IEEtranIEEEauthorblockN{
    \if@anonymize
        Anonymous
    \else
        #1
    \fi
    }}
\fi

\ifdefined\IEEEauthorblockA
\NewCommandCopy{\IEEtranIEEEauthorblockA}{\IEEEauthorblockA}
\renewcommand{\IEEEauthorblockA}[1]{\IEEtranIEEEauthorblockA{
    \if@anonymize
        Anonymous Affiliation
    \else
        #1
    \fi
    }}
\fi

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