Text Formattingblack textblocks because of confidential issue

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
letscho84
Posts: 7
Joined: Tue Jan 10, 2012 10:01 pm

black textblocks because of confidential issue

Post by letscho84 »

Hello together,

I worte this topic in a german forum http://mrunix.de/forums/showthread.php?t=72770 and the given answer there is not exactly what I want.
In the example below the text after \geheim{…} is erased but I want in addition that the now created free space is marked black. How can I do that? With or without big changes!

Code: Select all

\documentclass[12pt,a4paper]{article} 
 \usepackage[T1]{fontenc} 
 \usepackage{soul} 
 \makeatletter 
 \DeclareRobustCommand{\geheim}{% 
   \def\SOUL@everytoken{\phantom{\the\SOUL@token}}\SOUL@} 
 \makeatother 

\begin{document} 

ein Text mit einem geheimen Inhalt. 

ein Text mit einem \geheim{geheimen Inhalt}. 

\end{document}
Thanks for your help.

Regards, letscho

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

black textblocks because of confidential issue

Post by Stefan Kottwitz »

Hi,

you could combine \phantom, which hides the text, with \rule matching token width and a desired height. You could also use the height of the hidden token, but that is commonly different for each token. Using the same height looks better.

Code: Select all

\newlength{\tokwidth}
\newcommand{\black}[1]{%
  \settowidth{\tokwidth}{#1}%
  \rule[-.2\baselineskip]{\tokwidth}{\baselineskip}}
\makeatletter
\DeclareRobustCommand{\geheim}{%
  \def\SOUL@everytoken{\black{\phantom{\the\SOUL@token}}}\SOUL@}
\makeatother
Stefan
LaTeX.org admin
letscho84
Posts: 7
Joined: Tue Jan 10, 2012 10:01 pm

black textblocks because of confidential issue

Post by letscho84 »

Hello Stefan,

thanks for your help. When I implement your code in my example it works perfect. But when I would like to use

Code: Select all

\geheim{}
in a equation environment TeXNicCenter creats me the following error message:

! Package soul Error: Reconstruction failed.
See the soul package documentation for explanation.

Here is an example code:

Code: Select all

    \documentclass[12pt,a4paper]{article}
     \usepackage[T1]{fontenc}
     \usepackage{soul,xcolor}
    \newlength{\tokwidth}
    \newcommand{\black}[1]{%
      \settowidth{\tokwidth}{#1}%
      \rule[-.2\baselineskip]{\tokwidth}{\baselineskip}}
    \makeatletter
    \DeclareRobustCommand{\geheim}{%
      \def\SOUL@everytoken{\black{\phantom{\the\SOUL@token}}}\SOUL@}
    \makeatother

    \begin{document}

    ein Text mit einem geheimen Inhalt.

\begin{equation}
 1+2 = \geheim{3}
\end{equation}
    ein Text mit einem \geheim{geheimen Inhalt}.

    \end{document}
In the PDF the black bares are shown but the error massages irritates me a little bit.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

Re: black textblocks because of confidential issue

Post by Stefan Kottwitz »

With this code, I don't get this error message, it simply works. Perhaps you are doing something different which you did not show in the example.

Regarding overprinting complex math expressions, perhaps the height of the black block might need adjustment.

Stefan
LaTeX.org admin
letscho84
Posts: 7
Joined: Tue Jan 10, 2012 10:01 pm

black textblocks because of confidential issue

Post by letscho84 »

Hello Stefan,

I crosschecked with my file and find the problem within the siunitx. Here is the code
a of a bigger example.

Code: Select all

\documentclass[a4paper, 11pt, oneside]{book}

\usepackage{ngerman}
\usepackage[latin9]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[usenames,dvipsnames]{xcolor}

\usepackage[mode=text,per-mode=symbol,exponent-product = \cdot, list-units = single, range-units = single, output-decimal-marker ={,}]{siunitx}
\sisetup{list-final-separator = { \translate{und} },range-phrase = { \translate{bis} }, obeyfamily=false, mathrm=mathsf, textrm=sffamily}

\usepackage{soul}
    \newlength{\tokwidth}
    \newcommand{\black}[1]{%
      \settowidth{\tokwidth}{#1}%
      \rule[-.2\baselineskip]{\tokwidth}{\baselineskip}}
    \makeatletter
    \DeclareRobustCommand{\geheim}{%
      \def\SOUL@everytoken{\black{\phantom{\the\SOUL@token}}}\SOUL@}
    \makeatother

    \begin{document}

    ein Text mit einem geheimen Inhalt.

    ein Text mit einem \geheim{geheimen Inhalt}.
    
\begin{equation}
	\lambda = \geheim{a} + b \cdot T + c \cdot T^2
\end{equation}


\geheim{8,107em5}\si{\cubic\metre}

    \end{document}
Lars
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

black textblocks because of confidential issue

Post by josephwright »

This is 'works for me' with an up to date TeX system. What issue are you seeing? Could you post the output of \listfiles?
Joseph Wright
letscho84
Posts: 7
Joined: Tue Jan 10, 2012 10:01 pm

Re: black textblocks because of confidential issue

Post by letscho84 »

Hi Joseph,

what exactly do you mean with the output of \listfiles?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10344
Joined: Mon Mar 10, 2008 9:44 pm

black textblocks because of confidential issue

Post by Stefan Kottwitz »

Hi Lars,

if you would add \listfiles to your preamble, all used files and their versions would be written to the .log file and you could tell us your siunitx version.

I tested it with siunitx 2011/06/15 v2.2 (installed with TeX Live 2011 earlier) and could reproduce the error. Joseph is right, the current version works without this error. Now I tested with siunitx 2012/01/26 v2.4j.

So the recommendation is, update siunitx. Possibly you have to update further packages, such as expl3.

Stefan
LaTeX.org admin
Post Reply