How to black out a figure for confidential reasons?












17














I have a document, that contains critical parts. Now two documents should be generated. One version that is "balcked out" and one version that is all readable.



For pure text I found some hints using the soul package. See http://latex-community.org/forum/viewtopic.php?f=44&t=18190



Now I have the problem, that there are also some figures (drawn with tikz) that should be hidden. Is there a way to handle this?



Edit:
I got two very good answers how to do it. Unfortunately I use the externalization library of tikz. The criticat pictures I of course do not export to avoid problems with the file numbers. But the on compiling the other pictures (after one in a Btikzpicture or a ctikzpicture) have problems to compile as latex finds the tikzpicture but it seems not to see the enttikzpicture and therefor runs into trouble. Have you here also a solution. I tried using NewEnviron but this did not solve the problem as I think.



Example:



documentclass{article}
usepackage{tikz}
usetikzlibrary{external}
tikzexternalize
usepackage{adjustbox}
newififblackOut
% blackOuttrue
ifblackOut
newenvironment{ctikzpicture}
{tikzset{external/export next=false}
adjustbox{precode=phantom,bgcolor=black!10}
bgrouptikzpicture}
{endtikzpictureegroup}
else
newenvironment{ctikzpicture}
{tikzset{external/export next=false}
tikzpicture}
{endtikzpicture}
fi
begin{document}
begin{figure}[htbp]
centering
begin{tikzpicture}
draw (0,0) circle (1cm);
end{tikzpicture}
end{figure}
%
begin{figure}[htbp]
centering
begin{ctikzpicture}
draw (0,0) rectangle (1,1);
end{ctikzpicture}
caption{}
end{figure}
% Uncomment next lines for other error
% begin{figure}[htbp]
% centering
% begin{tikzpicture}
% draw (0,0) circle (2cm);
% end{tikzpicture}
% end{figure}
end{document}









share|improve this question




















  • 5




    The solution depends on what you call "document". "Blacking out" for the printed version is quite simpler than "blacking out" for the PDF file in a manner where the information is reliably absent from the file.
    – user9588
    Jun 5 '12 at 13:32










  • It would be optimal if it backs out even for the pdf file. But if you have an idea for only printing, that would also be very welcome.
    – Christian Wolf
    Jun 5 '12 at 13:45










  • Does it keep the text in the PDF when you use the phantom option? If not, you could try something like tex.stackexchange.com/questions/43069/… and just make the box black. (This is only for the text part, though, not for the figure.)
    – brian-ammon
    Jun 5 '12 at 13:50






  • 1




    For plain text there is the censor, which has facilities for censoring either the output PDF or the source .tex file.
    – Alan Munn
    Jun 5 '12 at 15:42










  • Would you please make a code example?
    – egreg
    Jun 5 '12 at 15:42
















17














I have a document, that contains critical parts. Now two documents should be generated. One version that is "balcked out" and one version that is all readable.



For pure text I found some hints using the soul package. See http://latex-community.org/forum/viewtopic.php?f=44&t=18190



Now I have the problem, that there are also some figures (drawn with tikz) that should be hidden. Is there a way to handle this?



Edit:
I got two very good answers how to do it. Unfortunately I use the externalization library of tikz. The criticat pictures I of course do not export to avoid problems with the file numbers. But the on compiling the other pictures (after one in a Btikzpicture or a ctikzpicture) have problems to compile as latex finds the tikzpicture but it seems not to see the enttikzpicture and therefor runs into trouble. Have you here also a solution. I tried using NewEnviron but this did not solve the problem as I think.



Example:



documentclass{article}
usepackage{tikz}
usetikzlibrary{external}
tikzexternalize
usepackage{adjustbox}
newififblackOut
% blackOuttrue
ifblackOut
newenvironment{ctikzpicture}
{tikzset{external/export next=false}
adjustbox{precode=phantom,bgcolor=black!10}
bgrouptikzpicture}
{endtikzpictureegroup}
else
newenvironment{ctikzpicture}
{tikzset{external/export next=false}
tikzpicture}
{endtikzpicture}
fi
begin{document}
begin{figure}[htbp]
centering
begin{tikzpicture}
draw (0,0) circle (1cm);
end{tikzpicture}
end{figure}
%
begin{figure}[htbp]
centering
begin{ctikzpicture}
draw (0,0) rectangle (1,1);
end{ctikzpicture}
caption{}
end{figure}
% Uncomment next lines for other error
% begin{figure}[htbp]
% centering
% begin{tikzpicture}
% draw (0,0) circle (2cm);
% end{tikzpicture}
% end{figure}
end{document}









share|improve this question




















  • 5




    The solution depends on what you call "document". "Blacking out" for the printed version is quite simpler than "blacking out" for the PDF file in a manner where the information is reliably absent from the file.
    – user9588
    Jun 5 '12 at 13:32










  • It would be optimal if it backs out even for the pdf file. But if you have an idea for only printing, that would also be very welcome.
    – Christian Wolf
    Jun 5 '12 at 13:45










  • Does it keep the text in the PDF when you use the phantom option? If not, you could try something like tex.stackexchange.com/questions/43069/… and just make the box black. (This is only for the text part, though, not for the figure.)
    – brian-ammon
    Jun 5 '12 at 13:50






  • 1




    For plain text there is the censor, which has facilities for censoring either the output PDF or the source .tex file.
    – Alan Munn
    Jun 5 '12 at 15:42










  • Would you please make a code example?
    – egreg
    Jun 5 '12 at 15:42














17












17








17


4





I have a document, that contains critical parts. Now two documents should be generated. One version that is "balcked out" and one version that is all readable.



For pure text I found some hints using the soul package. See http://latex-community.org/forum/viewtopic.php?f=44&t=18190



Now I have the problem, that there are also some figures (drawn with tikz) that should be hidden. Is there a way to handle this?



Edit:
I got two very good answers how to do it. Unfortunately I use the externalization library of tikz. The criticat pictures I of course do not export to avoid problems with the file numbers. But the on compiling the other pictures (after one in a Btikzpicture or a ctikzpicture) have problems to compile as latex finds the tikzpicture but it seems not to see the enttikzpicture and therefor runs into trouble. Have you here also a solution. I tried using NewEnviron but this did not solve the problem as I think.



Example:



documentclass{article}
usepackage{tikz}
usetikzlibrary{external}
tikzexternalize
usepackage{adjustbox}
newififblackOut
% blackOuttrue
ifblackOut
newenvironment{ctikzpicture}
{tikzset{external/export next=false}
adjustbox{precode=phantom,bgcolor=black!10}
bgrouptikzpicture}
{endtikzpictureegroup}
else
newenvironment{ctikzpicture}
{tikzset{external/export next=false}
tikzpicture}
{endtikzpicture}
fi
begin{document}
begin{figure}[htbp]
centering
begin{tikzpicture}
draw (0,0) circle (1cm);
end{tikzpicture}
end{figure}
%
begin{figure}[htbp]
centering
begin{ctikzpicture}
draw (0,0) rectangle (1,1);
end{ctikzpicture}
caption{}
end{figure}
% Uncomment next lines for other error
% begin{figure}[htbp]
% centering
% begin{tikzpicture}
% draw (0,0) circle (2cm);
% end{tikzpicture}
% end{figure}
end{document}









share|improve this question















I have a document, that contains critical parts. Now two documents should be generated. One version that is "balcked out" and one version that is all readable.



For pure text I found some hints using the soul package. See http://latex-community.org/forum/viewtopic.php?f=44&t=18190



Now I have the problem, that there are also some figures (drawn with tikz) that should be hidden. Is there a way to handle this?



Edit:
I got two very good answers how to do it. Unfortunately I use the externalization library of tikz. The criticat pictures I of course do not export to avoid problems with the file numbers. But the on compiling the other pictures (after one in a Btikzpicture or a ctikzpicture) have problems to compile as latex finds the tikzpicture but it seems not to see the enttikzpicture and therefor runs into trouble. Have you here also a solution. I tried using NewEnviron but this did not solve the problem as I think.



Example:



documentclass{article}
usepackage{tikz}
usetikzlibrary{external}
tikzexternalize
usepackage{adjustbox}
newififblackOut
% blackOuttrue
ifblackOut
newenvironment{ctikzpicture}
{tikzset{external/export next=false}
adjustbox{precode=phantom,bgcolor=black!10}
bgrouptikzpicture}
{endtikzpictureegroup}
else
newenvironment{ctikzpicture}
{tikzset{external/export next=false}
tikzpicture}
{endtikzpicture}
fi
begin{document}
begin{figure}[htbp]
centering
begin{tikzpicture}
draw (0,0) circle (1cm);
end{tikzpicture}
end{figure}
%
begin{figure}[htbp]
centering
begin{ctikzpicture}
draw (0,0) rectangle (1,1);
end{ctikzpicture}
caption{}
end{figure}
% Uncomment next lines for other error
% begin{figure}[htbp]
% centering
% begin{tikzpicture}
% draw (0,0) circle (2cm);
% end{tikzpicture}
% end{figure}
end{document}






tikz-pgf pdftex






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 5 '12 at 17:17

























asked Jun 5 '12 at 13:27









Christian Wolf

8581923




8581923








  • 5




    The solution depends on what you call "document". "Blacking out" for the printed version is quite simpler than "blacking out" for the PDF file in a manner where the information is reliably absent from the file.
    – user9588
    Jun 5 '12 at 13:32










  • It would be optimal if it backs out even for the pdf file. But if you have an idea for only printing, that would also be very welcome.
    – Christian Wolf
    Jun 5 '12 at 13:45










  • Does it keep the text in the PDF when you use the phantom option? If not, you could try something like tex.stackexchange.com/questions/43069/… and just make the box black. (This is only for the text part, though, not for the figure.)
    – brian-ammon
    Jun 5 '12 at 13:50






  • 1




    For plain text there is the censor, which has facilities for censoring either the output PDF or the source .tex file.
    – Alan Munn
    Jun 5 '12 at 15:42










  • Would you please make a code example?
    – egreg
    Jun 5 '12 at 15:42














  • 5




    The solution depends on what you call "document". "Blacking out" for the printed version is quite simpler than "blacking out" for the PDF file in a manner where the information is reliably absent from the file.
    – user9588
    Jun 5 '12 at 13:32










  • It would be optimal if it backs out even for the pdf file. But if you have an idea for only printing, that would also be very welcome.
    – Christian Wolf
    Jun 5 '12 at 13:45










  • Does it keep the text in the PDF when you use the phantom option? If not, you could try something like tex.stackexchange.com/questions/43069/… and just make the box black. (This is only for the text part, though, not for the figure.)
    – brian-ammon
    Jun 5 '12 at 13:50






  • 1




    For plain text there is the censor, which has facilities for censoring either the output PDF or the source .tex file.
    – Alan Munn
    Jun 5 '12 at 15:42










  • Would you please make a code example?
    – egreg
    Jun 5 '12 at 15:42








5




5




The solution depends on what you call "document". "Blacking out" for the printed version is quite simpler than "blacking out" for the PDF file in a manner where the information is reliably absent from the file.
– user9588
Jun 5 '12 at 13:32




The solution depends on what you call "document". "Blacking out" for the printed version is quite simpler than "blacking out" for the PDF file in a manner where the information is reliably absent from the file.
– user9588
Jun 5 '12 at 13:32












It would be optimal if it backs out even for the pdf file. But if you have an idea for only printing, that would also be very welcome.
– Christian Wolf
Jun 5 '12 at 13:45




It would be optimal if it backs out even for the pdf file. But if you have an idea for only printing, that would also be very welcome.
– Christian Wolf
Jun 5 '12 at 13:45












Does it keep the text in the PDF when you use the phantom option? If not, you could try something like tex.stackexchange.com/questions/43069/… and just make the box black. (This is only for the text part, though, not for the figure.)
– brian-ammon
Jun 5 '12 at 13:50




Does it keep the text in the PDF when you use the phantom option? If not, you could try something like tex.stackexchange.com/questions/43069/… and just make the box black. (This is only for the text part, though, not for the figure.)
– brian-ammon
Jun 5 '12 at 13:50




1




1




For plain text there is the censor, which has facilities for censoring either the output PDF or the source .tex file.
– Alan Munn
Jun 5 '12 at 15:42




For plain text there is the censor, which has facilities for censoring either the output PDF or the source .tex file.
– Alan Munn
Jun 5 '12 at 15:42












Would you please make a code example?
– egreg
Jun 5 '12 at 15:42




Would you please make a code example?
– egreg
Jun 5 '12 at 15:42










5 Answers
5






active

oldest

votes


















14














Just define a Btikzpicture environment that can behave differently under a set conditional and use it for the pictures that you want to selectively omit:



documentclass{article}
usepackage{tikz}

newififsecret
% secrettrue % uncomment for the hidden version

ifsecret
%%% code for blanking TikZ pictures
newsavebox{Btpbox}
newenvironment{Btikzpicture}
{begin{lrbox}{Btpbox}begin{tikzpicture}}
{end{tikzpicture}end{lrbox}%
fboxsep=-fboxrulefbox{omissionphantom{usebox{Btpbox}}}}

newcommand{omission}{makebox[0pt][l]{,tiny OMITTEDstrut}}
%%%
else
%%% code for normal printing
newenvironment{Btikzpicture}{tikzpicture}{endtikzpicture}
%%%
fi

begin{document}
tikzset{
every node/.style={
circle,
draw,
solid,
fill=black!50,
inner sep=0pt,
minimum width=4pt
}
}
begin{Btikzpicture}[thick,scale=0.8,->,shorten >=2pt]
draw (0,0) node {} -- (1,1) node {};
draw (1,1) node {} -- (2,1) node {};
draw (2,1) node {} -- (3,2) node {};
draw (3,2) node {} -- (4,1) node {};

draw (0,2) node {} -- (1,1) node {};
draw (1,2) node {} -- (2,1) [dashed] node {};
draw (2,1) node {} -- (3,2) node {};
draw (3,2) node {} -- (4,1) node {};

draw (2,1) node {} -- (3,0) [dashed] node {};
draw (2,1) node {} -- (2,0) [dashed] node {};
draw (3,0) node {} -- (4,0) [dashed] node {};
draw (3,0) node {} -- (4,-1) [dashed] node {};
draw (1,1) node {} -- (1,0) [dashed] node {};
end{Btikzpicture}

end{document}


(The picture code is taken from an answer by Jake.)



When secrettrue is uncommented, only a frame of the correct size will be drawn; only the metric information will be in the final output.






share|improve this answer































    11














    You can use adjustbox to replace the content with a black (or gray, to save ink) rectangle.



    Note that this solution will not write the censored content into the PDF.



    documentclass{article}

    usepackage{adjustbox}
    usepackage{tikz}

    iffalse
    newenvironment{ctikzpicture}{%
    tikzpicture
    }{%
    endtikzpicture
    }
    else
    newenvironment{ctikzpicture}{%
    adjustbox{precode=phantom,bgcolor=black!10}bgroup
    tikzpicture
    }{%
    endtikzpicture
    egroup
    }
    fi

    begin{document}

    begin{ctikzpicture}[thick]
    draw (0,0) -- (10,10);
    node at (5,5) {Secret information};
    end{ctikzpicture}

    end{document}




    With recent version of adjustbox (i.e. v1.1 2018/04/08) you can just write phantom as a key and also add some "Censored" text on top of it.



    documentclass{article}

    usepackage{adjustbox}[2018/04/08]
    usepackage{tikz}

    iffalse
    newenvironment{ctikzpicture}{%
    tikzpicture
    }{%
    endtikzpicture
    }
    else
    newenvironment{ctikzpicture}{%
    adjustbox{phantom,bgcolor=black!10,foreground={rotate=45}{sffamily Consored!}}bgroup
    tikzpicture
    }{%
    endtikzpicture
    egroup
    }
    fi

    usepackage{blindtext}
    begin{document}
    blindtext

    begin{ctikzpicture}[thick]
    draw (0,0) -- (10,10);
    node at (5,5) {Secret information};
    end{ctikzpicture}

    blindtext
    end{document}


    enter image description here






    share|improve this answer























    • consored is a typo, isn't?
      – God Must Be Crazy
      6 mins ago



















    4














    The censorbox command from my censor package can block out boxed material like figures, tables, etc. Here is an excerpt from the docs:



    enter image description hereenter image description here






    share|improve this answer





























      3














      Here is a tikz solution, set the scale to a low value and use color to blank it out (there are possibly more solutions, such as xshift=-2000pt).



      documentclass{article}

      usepackage{tikz}
      usetikzlibrary{calc}
      tikzset{every picture/.style={color=white,scale=0.0001}}
      begin{document}
      abcd

      begin{tikzpicture}
      coordinate (1) at (0.1,0.2);
      coordinate (2) at (0.2,0.7);
      coordinate (3) at (0.4,-0.3);

      draw let p1 = (1),
      p2 = (2),
      p3 = (3),
      n{denom} = {(x1 - x2)*(x1 - x3)*(x2-x3)},
      n{A} = {(x3*(y2-y1) + x2*(y1-y3) + x1*(y3-y2))/n{denom}},
      n{B} = {(x3*x3*(y1-y2) + x2*x2*(y3-y1)+x1*x1*(y2-y3))/n{denom}},
      n{C} = {(x2*x3*(x2-x3)*y1 + x3*x1*(x3-x1)*y2 + x1*x2*(x1-x2)*y3)/n{denom}} in
      plot[domain=x1:x3] (x,{n{A}*x*x+n{B}*x + n{C}});
      end{tikzpicture}

      abcd
      end{document}


      As mentioned in the comments though, you need to decide if you sending the original file or not. Other strategies would include importing the figures from files, which you do not include in the final draft you sending out.






      share|improve this answer





























        3














        As you are using externalization anyway, you could also delegate the blackening to some external program that is invoked for the image to externalize via the external/system call key. The amazing thing (I have learned it from Andrew Stacey in the process of answering this question) about this key is that you can pass an arbitrary sequence of commands as long as the final output is a PDF.



        In the following, I use ImageMagick's convert utility to replace the generated PDF by one with a simply filled canvas immediately after it has been generated by pdflatex. By defining own styles, the confidential mode can be activated/deactivated with tikzset globally or on a per-picture base.



        documentclass[a4paper, 11pt]{article}

        usepackage[T1]{fontenc}
        usepackage{tikz}

        % setup externalization
        usetikzlibrary{external}
        tikzexternalize
        tikzset{
        confidential tikz/.style={
        external/system call={%
        pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource";
        convert "image".pdf -fill Tan -draw 'color 0,0 reset' "image".pdf}
        },
        public tikz/.style={
        external/system call={%
        pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource"}
        }
        }


        tikzset{confidential tikz}

        begin{document}

        begin{tikzpicture}
        draw[thick,rounded corners=8pt]
        (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
        end{tikzpicture}

        tikzset{public tikz}

        begin{tikzpicture}
        draw[thick,rounded corners=8pt]
        (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
        end{tikzpicture}

        end{document}


        enter image description here






        share|improve this answer























        • This is based on Image Magic right?
          – Christian Wolf
          Jun 5 '12 at 17:18










        • @ChristianWolf: Right. I have now explained this in detail.
          – Daniel
          Jun 5 '12 at 19:00










        • @ChristianWolf: Note also, that with this solution there is no need to disable externalization for the confidential images, as the generated image file itself is overwritten by the convert-generated one.
          – Daniel
          Jun 5 '12 at 22:14











        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "85"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f58649%2fhow-to-black-out-a-figure-for-confidential-reasons%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        14














        Just define a Btikzpicture environment that can behave differently under a set conditional and use it for the pictures that you want to selectively omit:



        documentclass{article}
        usepackage{tikz}

        newififsecret
        % secrettrue % uncomment for the hidden version

        ifsecret
        %%% code for blanking TikZ pictures
        newsavebox{Btpbox}
        newenvironment{Btikzpicture}
        {begin{lrbox}{Btpbox}begin{tikzpicture}}
        {end{tikzpicture}end{lrbox}%
        fboxsep=-fboxrulefbox{omissionphantom{usebox{Btpbox}}}}

        newcommand{omission}{makebox[0pt][l]{,tiny OMITTEDstrut}}
        %%%
        else
        %%% code for normal printing
        newenvironment{Btikzpicture}{tikzpicture}{endtikzpicture}
        %%%
        fi

        begin{document}
        tikzset{
        every node/.style={
        circle,
        draw,
        solid,
        fill=black!50,
        inner sep=0pt,
        minimum width=4pt
        }
        }
        begin{Btikzpicture}[thick,scale=0.8,->,shorten >=2pt]
        draw (0,0) node {} -- (1,1) node {};
        draw (1,1) node {} -- (2,1) node {};
        draw (2,1) node {} -- (3,2) node {};
        draw (3,2) node {} -- (4,1) node {};

        draw (0,2) node {} -- (1,1) node {};
        draw (1,2) node {} -- (2,1) [dashed] node {};
        draw (2,1) node {} -- (3,2) node {};
        draw (3,2) node {} -- (4,1) node {};

        draw (2,1) node {} -- (3,0) [dashed] node {};
        draw (2,1) node {} -- (2,0) [dashed] node {};
        draw (3,0) node {} -- (4,0) [dashed] node {};
        draw (3,0) node {} -- (4,-1) [dashed] node {};
        draw (1,1) node {} -- (1,0) [dashed] node {};
        end{Btikzpicture}

        end{document}


        (The picture code is taken from an answer by Jake.)



        When secrettrue is uncommented, only a frame of the correct size will be drawn; only the metric information will be in the final output.






        share|improve this answer




























          14














          Just define a Btikzpicture environment that can behave differently under a set conditional and use it for the pictures that you want to selectively omit:



          documentclass{article}
          usepackage{tikz}

          newififsecret
          % secrettrue % uncomment for the hidden version

          ifsecret
          %%% code for blanking TikZ pictures
          newsavebox{Btpbox}
          newenvironment{Btikzpicture}
          {begin{lrbox}{Btpbox}begin{tikzpicture}}
          {end{tikzpicture}end{lrbox}%
          fboxsep=-fboxrulefbox{omissionphantom{usebox{Btpbox}}}}

          newcommand{omission}{makebox[0pt][l]{,tiny OMITTEDstrut}}
          %%%
          else
          %%% code for normal printing
          newenvironment{Btikzpicture}{tikzpicture}{endtikzpicture}
          %%%
          fi

          begin{document}
          tikzset{
          every node/.style={
          circle,
          draw,
          solid,
          fill=black!50,
          inner sep=0pt,
          minimum width=4pt
          }
          }
          begin{Btikzpicture}[thick,scale=0.8,->,shorten >=2pt]
          draw (0,0) node {} -- (1,1) node {};
          draw (1,1) node {} -- (2,1) node {};
          draw (2,1) node {} -- (3,2) node {};
          draw (3,2) node {} -- (4,1) node {};

          draw (0,2) node {} -- (1,1) node {};
          draw (1,2) node {} -- (2,1) [dashed] node {};
          draw (2,1) node {} -- (3,2) node {};
          draw (3,2) node {} -- (4,1) node {};

          draw (2,1) node {} -- (3,0) [dashed] node {};
          draw (2,1) node {} -- (2,0) [dashed] node {};
          draw (3,0) node {} -- (4,0) [dashed] node {};
          draw (3,0) node {} -- (4,-1) [dashed] node {};
          draw (1,1) node {} -- (1,0) [dashed] node {};
          end{Btikzpicture}

          end{document}


          (The picture code is taken from an answer by Jake.)



          When secrettrue is uncommented, only a frame of the correct size will be drawn; only the metric information will be in the final output.






          share|improve this answer


























            14












            14








            14






            Just define a Btikzpicture environment that can behave differently under a set conditional and use it for the pictures that you want to selectively omit:



            documentclass{article}
            usepackage{tikz}

            newififsecret
            % secrettrue % uncomment for the hidden version

            ifsecret
            %%% code for blanking TikZ pictures
            newsavebox{Btpbox}
            newenvironment{Btikzpicture}
            {begin{lrbox}{Btpbox}begin{tikzpicture}}
            {end{tikzpicture}end{lrbox}%
            fboxsep=-fboxrulefbox{omissionphantom{usebox{Btpbox}}}}

            newcommand{omission}{makebox[0pt][l]{,tiny OMITTEDstrut}}
            %%%
            else
            %%% code for normal printing
            newenvironment{Btikzpicture}{tikzpicture}{endtikzpicture}
            %%%
            fi

            begin{document}
            tikzset{
            every node/.style={
            circle,
            draw,
            solid,
            fill=black!50,
            inner sep=0pt,
            minimum width=4pt
            }
            }
            begin{Btikzpicture}[thick,scale=0.8,->,shorten >=2pt]
            draw (0,0) node {} -- (1,1) node {};
            draw (1,1) node {} -- (2,1) node {};
            draw (2,1) node {} -- (3,2) node {};
            draw (3,2) node {} -- (4,1) node {};

            draw (0,2) node {} -- (1,1) node {};
            draw (1,2) node {} -- (2,1) [dashed] node {};
            draw (2,1) node {} -- (3,2) node {};
            draw (3,2) node {} -- (4,1) node {};

            draw (2,1) node {} -- (3,0) [dashed] node {};
            draw (2,1) node {} -- (2,0) [dashed] node {};
            draw (3,0) node {} -- (4,0) [dashed] node {};
            draw (3,0) node {} -- (4,-1) [dashed] node {};
            draw (1,1) node {} -- (1,0) [dashed] node {};
            end{Btikzpicture}

            end{document}


            (The picture code is taken from an answer by Jake.)



            When secrettrue is uncommented, only a frame of the correct size will be drawn; only the metric information will be in the final output.






            share|improve this answer














            Just define a Btikzpicture environment that can behave differently under a set conditional and use it for the pictures that you want to selectively omit:



            documentclass{article}
            usepackage{tikz}

            newififsecret
            % secrettrue % uncomment for the hidden version

            ifsecret
            %%% code for blanking TikZ pictures
            newsavebox{Btpbox}
            newenvironment{Btikzpicture}
            {begin{lrbox}{Btpbox}begin{tikzpicture}}
            {end{tikzpicture}end{lrbox}%
            fboxsep=-fboxrulefbox{omissionphantom{usebox{Btpbox}}}}

            newcommand{omission}{makebox[0pt][l]{,tiny OMITTEDstrut}}
            %%%
            else
            %%% code for normal printing
            newenvironment{Btikzpicture}{tikzpicture}{endtikzpicture}
            %%%
            fi

            begin{document}
            tikzset{
            every node/.style={
            circle,
            draw,
            solid,
            fill=black!50,
            inner sep=0pt,
            minimum width=4pt
            }
            }
            begin{Btikzpicture}[thick,scale=0.8,->,shorten >=2pt]
            draw (0,0) node {} -- (1,1) node {};
            draw (1,1) node {} -- (2,1) node {};
            draw (2,1) node {} -- (3,2) node {};
            draw (3,2) node {} -- (4,1) node {};

            draw (0,2) node {} -- (1,1) node {};
            draw (1,2) node {} -- (2,1) [dashed] node {};
            draw (2,1) node {} -- (3,2) node {};
            draw (3,2) node {} -- (4,1) node {};

            draw (2,1) node {} -- (3,0) [dashed] node {};
            draw (2,1) node {} -- (2,0) [dashed] node {};
            draw (3,0) node {} -- (4,0) [dashed] node {};
            draw (3,0) node {} -- (4,-1) [dashed] node {};
            draw (1,1) node {} -- (1,0) [dashed] node {};
            end{Btikzpicture}

            end{document}


            (The picture code is taken from an answer by Jake.)



            When secrettrue is uncommented, only a frame of the correct size will be drawn; only the metric information will be in the final output.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 5 '12 at 14:03

























            answered Jun 5 '12 at 13:48









            egreg

            708k8618813163




            708k8618813163























                11














                You can use adjustbox to replace the content with a black (or gray, to save ink) rectangle.



                Note that this solution will not write the censored content into the PDF.



                documentclass{article}

                usepackage{adjustbox}
                usepackage{tikz}

                iffalse
                newenvironment{ctikzpicture}{%
                tikzpicture
                }{%
                endtikzpicture
                }
                else
                newenvironment{ctikzpicture}{%
                adjustbox{precode=phantom,bgcolor=black!10}bgroup
                tikzpicture
                }{%
                endtikzpicture
                egroup
                }
                fi

                begin{document}

                begin{ctikzpicture}[thick]
                draw (0,0) -- (10,10);
                node at (5,5) {Secret information};
                end{ctikzpicture}

                end{document}




                With recent version of adjustbox (i.e. v1.1 2018/04/08) you can just write phantom as a key and also add some "Censored" text on top of it.



                documentclass{article}

                usepackage{adjustbox}[2018/04/08]
                usepackage{tikz}

                iffalse
                newenvironment{ctikzpicture}{%
                tikzpicture
                }{%
                endtikzpicture
                }
                else
                newenvironment{ctikzpicture}{%
                adjustbox{phantom,bgcolor=black!10,foreground={rotate=45}{sffamily Consored!}}bgroup
                tikzpicture
                }{%
                endtikzpicture
                egroup
                }
                fi

                usepackage{blindtext}
                begin{document}
                blindtext

                begin{ctikzpicture}[thick]
                draw (0,0) -- (10,10);
                node at (5,5) {Secret information};
                end{ctikzpicture}

                blindtext
                end{document}


                enter image description here






                share|improve this answer























                • consored is a typo, isn't?
                  – God Must Be Crazy
                  6 mins ago
















                11














                You can use adjustbox to replace the content with a black (or gray, to save ink) rectangle.



                Note that this solution will not write the censored content into the PDF.



                documentclass{article}

                usepackage{adjustbox}
                usepackage{tikz}

                iffalse
                newenvironment{ctikzpicture}{%
                tikzpicture
                }{%
                endtikzpicture
                }
                else
                newenvironment{ctikzpicture}{%
                adjustbox{precode=phantom,bgcolor=black!10}bgroup
                tikzpicture
                }{%
                endtikzpicture
                egroup
                }
                fi

                begin{document}

                begin{ctikzpicture}[thick]
                draw (0,0) -- (10,10);
                node at (5,5) {Secret information};
                end{ctikzpicture}

                end{document}




                With recent version of adjustbox (i.e. v1.1 2018/04/08) you can just write phantom as a key and also add some "Censored" text on top of it.



                documentclass{article}

                usepackage{adjustbox}[2018/04/08]
                usepackage{tikz}

                iffalse
                newenvironment{ctikzpicture}{%
                tikzpicture
                }{%
                endtikzpicture
                }
                else
                newenvironment{ctikzpicture}{%
                adjustbox{phantom,bgcolor=black!10,foreground={rotate=45}{sffamily Consored!}}bgroup
                tikzpicture
                }{%
                endtikzpicture
                egroup
                }
                fi

                usepackage{blindtext}
                begin{document}
                blindtext

                begin{ctikzpicture}[thick]
                draw (0,0) -- (10,10);
                node at (5,5) {Secret information};
                end{ctikzpicture}

                blindtext
                end{document}


                enter image description here






                share|improve this answer























                • consored is a typo, isn't?
                  – God Must Be Crazy
                  6 mins ago














                11












                11








                11






                You can use adjustbox to replace the content with a black (or gray, to save ink) rectangle.



                Note that this solution will not write the censored content into the PDF.



                documentclass{article}

                usepackage{adjustbox}
                usepackage{tikz}

                iffalse
                newenvironment{ctikzpicture}{%
                tikzpicture
                }{%
                endtikzpicture
                }
                else
                newenvironment{ctikzpicture}{%
                adjustbox{precode=phantom,bgcolor=black!10}bgroup
                tikzpicture
                }{%
                endtikzpicture
                egroup
                }
                fi

                begin{document}

                begin{ctikzpicture}[thick]
                draw (0,0) -- (10,10);
                node at (5,5) {Secret information};
                end{ctikzpicture}

                end{document}




                With recent version of adjustbox (i.e. v1.1 2018/04/08) you can just write phantom as a key and also add some "Censored" text on top of it.



                documentclass{article}

                usepackage{adjustbox}[2018/04/08]
                usepackage{tikz}

                iffalse
                newenvironment{ctikzpicture}{%
                tikzpicture
                }{%
                endtikzpicture
                }
                else
                newenvironment{ctikzpicture}{%
                adjustbox{phantom,bgcolor=black!10,foreground={rotate=45}{sffamily Consored!}}bgroup
                tikzpicture
                }{%
                endtikzpicture
                egroup
                }
                fi

                usepackage{blindtext}
                begin{document}
                blindtext

                begin{ctikzpicture}[thick]
                draw (0,0) -- (10,10);
                node at (5,5) {Secret information};
                end{ctikzpicture}

                blindtext
                end{document}


                enter image description here






                share|improve this answer














                You can use adjustbox to replace the content with a black (or gray, to save ink) rectangle.



                Note that this solution will not write the censored content into the PDF.



                documentclass{article}

                usepackage{adjustbox}
                usepackage{tikz}

                iffalse
                newenvironment{ctikzpicture}{%
                tikzpicture
                }{%
                endtikzpicture
                }
                else
                newenvironment{ctikzpicture}{%
                adjustbox{precode=phantom,bgcolor=black!10}bgroup
                tikzpicture
                }{%
                endtikzpicture
                egroup
                }
                fi

                begin{document}

                begin{ctikzpicture}[thick]
                draw (0,0) -- (10,10);
                node at (5,5) {Secret information};
                end{ctikzpicture}

                end{document}




                With recent version of adjustbox (i.e. v1.1 2018/04/08) you can just write phantom as a key and also add some "Censored" text on top of it.



                documentclass{article}

                usepackage{adjustbox}[2018/04/08]
                usepackage{tikz}

                iffalse
                newenvironment{ctikzpicture}{%
                tikzpicture
                }{%
                endtikzpicture
                }
                else
                newenvironment{ctikzpicture}{%
                adjustbox{phantom,bgcolor=black!10,foreground={rotate=45}{sffamily Consored!}}bgroup
                tikzpicture
                }{%
                endtikzpicture
                egroup
                }
                fi

                usepackage{blindtext}
                begin{document}
                blindtext

                begin{ctikzpicture}[thick]
                draw (0,0) -- (10,10);
                node at (5,5) {Secret information};
                end{ctikzpicture}

                blindtext
                end{document}


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 9 mins ago

























                answered Jun 5 '12 at 13:58









                Martin Scharrer

                198k45632814




                198k45632814












                • consored is a typo, isn't?
                  – God Must Be Crazy
                  6 mins ago


















                • consored is a typo, isn't?
                  – God Must Be Crazy
                  6 mins ago
















                consored is a typo, isn't?
                – God Must Be Crazy
                6 mins ago




                consored is a typo, isn't?
                – God Must Be Crazy
                6 mins ago











                4














                The censorbox command from my censor package can block out boxed material like figures, tables, etc. Here is an excerpt from the docs:



                enter image description hereenter image description here






                share|improve this answer


























                  4














                  The censorbox command from my censor package can block out boxed material like figures, tables, etc. Here is an excerpt from the docs:



                  enter image description hereenter image description here






                  share|improve this answer
























                    4












                    4








                    4






                    The censorbox command from my censor package can block out boxed material like figures, tables, etc. Here is an excerpt from the docs:



                    enter image description hereenter image description here






                    share|improve this answer












                    The censorbox command from my censor package can block out boxed material like figures, tables, etc. Here is an excerpt from the docs:



                    enter image description hereenter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 26 '13 at 18:26









                    Steven B. Segletes

                    152k9192400




                    152k9192400























                        3














                        Here is a tikz solution, set the scale to a low value and use color to blank it out (there are possibly more solutions, such as xshift=-2000pt).



                        documentclass{article}

                        usepackage{tikz}
                        usetikzlibrary{calc}
                        tikzset{every picture/.style={color=white,scale=0.0001}}
                        begin{document}
                        abcd

                        begin{tikzpicture}
                        coordinate (1) at (0.1,0.2);
                        coordinate (2) at (0.2,0.7);
                        coordinate (3) at (0.4,-0.3);

                        draw let p1 = (1),
                        p2 = (2),
                        p3 = (3),
                        n{denom} = {(x1 - x2)*(x1 - x3)*(x2-x3)},
                        n{A} = {(x3*(y2-y1) + x2*(y1-y3) + x1*(y3-y2))/n{denom}},
                        n{B} = {(x3*x3*(y1-y2) + x2*x2*(y3-y1)+x1*x1*(y2-y3))/n{denom}},
                        n{C} = {(x2*x3*(x2-x3)*y1 + x3*x1*(x3-x1)*y2 + x1*x2*(x1-x2)*y3)/n{denom}} in
                        plot[domain=x1:x3] (x,{n{A}*x*x+n{B}*x + n{C}});
                        end{tikzpicture}

                        abcd
                        end{document}


                        As mentioned in the comments though, you need to decide if you sending the original file or not. Other strategies would include importing the figures from files, which you do not include in the final draft you sending out.






                        share|improve this answer


























                          3














                          Here is a tikz solution, set the scale to a low value and use color to blank it out (there are possibly more solutions, such as xshift=-2000pt).



                          documentclass{article}

                          usepackage{tikz}
                          usetikzlibrary{calc}
                          tikzset{every picture/.style={color=white,scale=0.0001}}
                          begin{document}
                          abcd

                          begin{tikzpicture}
                          coordinate (1) at (0.1,0.2);
                          coordinate (2) at (0.2,0.7);
                          coordinate (3) at (0.4,-0.3);

                          draw let p1 = (1),
                          p2 = (2),
                          p3 = (3),
                          n{denom} = {(x1 - x2)*(x1 - x3)*(x2-x3)},
                          n{A} = {(x3*(y2-y1) + x2*(y1-y3) + x1*(y3-y2))/n{denom}},
                          n{B} = {(x3*x3*(y1-y2) + x2*x2*(y3-y1)+x1*x1*(y2-y3))/n{denom}},
                          n{C} = {(x2*x3*(x2-x3)*y1 + x3*x1*(x3-x1)*y2 + x1*x2*(x1-x2)*y3)/n{denom}} in
                          plot[domain=x1:x3] (x,{n{A}*x*x+n{B}*x + n{C}});
                          end{tikzpicture}

                          abcd
                          end{document}


                          As mentioned in the comments though, you need to decide if you sending the original file or not. Other strategies would include importing the figures from files, which you do not include in the final draft you sending out.






                          share|improve this answer
























                            3












                            3








                            3






                            Here is a tikz solution, set the scale to a low value and use color to blank it out (there are possibly more solutions, such as xshift=-2000pt).



                            documentclass{article}

                            usepackage{tikz}
                            usetikzlibrary{calc}
                            tikzset{every picture/.style={color=white,scale=0.0001}}
                            begin{document}
                            abcd

                            begin{tikzpicture}
                            coordinate (1) at (0.1,0.2);
                            coordinate (2) at (0.2,0.7);
                            coordinate (3) at (0.4,-0.3);

                            draw let p1 = (1),
                            p2 = (2),
                            p3 = (3),
                            n{denom} = {(x1 - x2)*(x1 - x3)*(x2-x3)},
                            n{A} = {(x3*(y2-y1) + x2*(y1-y3) + x1*(y3-y2))/n{denom}},
                            n{B} = {(x3*x3*(y1-y2) + x2*x2*(y3-y1)+x1*x1*(y2-y3))/n{denom}},
                            n{C} = {(x2*x3*(x2-x3)*y1 + x3*x1*(x3-x1)*y2 + x1*x2*(x1-x2)*y3)/n{denom}} in
                            plot[domain=x1:x3] (x,{n{A}*x*x+n{B}*x + n{C}});
                            end{tikzpicture}

                            abcd
                            end{document}


                            As mentioned in the comments though, you need to decide if you sending the original file or not. Other strategies would include importing the figures from files, which you do not include in the final draft you sending out.






                            share|improve this answer












                            Here is a tikz solution, set the scale to a low value and use color to blank it out (there are possibly more solutions, such as xshift=-2000pt).



                            documentclass{article}

                            usepackage{tikz}
                            usetikzlibrary{calc}
                            tikzset{every picture/.style={color=white,scale=0.0001}}
                            begin{document}
                            abcd

                            begin{tikzpicture}
                            coordinate (1) at (0.1,0.2);
                            coordinate (2) at (0.2,0.7);
                            coordinate (3) at (0.4,-0.3);

                            draw let p1 = (1),
                            p2 = (2),
                            p3 = (3),
                            n{denom} = {(x1 - x2)*(x1 - x3)*(x2-x3)},
                            n{A} = {(x3*(y2-y1) + x2*(y1-y3) + x1*(y3-y2))/n{denom}},
                            n{B} = {(x3*x3*(y1-y2) + x2*x2*(y3-y1)+x1*x1*(y2-y3))/n{denom}},
                            n{C} = {(x2*x3*(x2-x3)*y1 + x3*x1*(x3-x1)*y2 + x1*x2*(x1-x2)*y3)/n{denom}} in
                            plot[domain=x1:x3] (x,{n{A}*x*x+n{B}*x + n{C}});
                            end{tikzpicture}

                            abcd
                            end{document}


                            As mentioned in the comments though, you need to decide if you sending the original file or not. Other strategies would include importing the figures from files, which you do not include in the final draft you sending out.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jun 5 '12 at 14:59









                            Yiannis Lazarides

                            91.9k20232511




                            91.9k20232511























                                3














                                As you are using externalization anyway, you could also delegate the blackening to some external program that is invoked for the image to externalize via the external/system call key. The amazing thing (I have learned it from Andrew Stacey in the process of answering this question) about this key is that you can pass an arbitrary sequence of commands as long as the final output is a PDF.



                                In the following, I use ImageMagick's convert utility to replace the generated PDF by one with a simply filled canvas immediately after it has been generated by pdflatex. By defining own styles, the confidential mode can be activated/deactivated with tikzset globally or on a per-picture base.



                                documentclass[a4paper, 11pt]{article}

                                usepackage[T1]{fontenc}
                                usepackage{tikz}

                                % setup externalization
                                usetikzlibrary{external}
                                tikzexternalize
                                tikzset{
                                confidential tikz/.style={
                                external/system call={%
                                pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource";
                                convert "image".pdf -fill Tan -draw 'color 0,0 reset' "image".pdf}
                                },
                                public tikz/.style={
                                external/system call={%
                                pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource"}
                                }
                                }


                                tikzset{confidential tikz}

                                begin{document}

                                begin{tikzpicture}
                                draw[thick,rounded corners=8pt]
                                (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
                                end{tikzpicture}

                                tikzset{public tikz}

                                begin{tikzpicture}
                                draw[thick,rounded corners=8pt]
                                (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
                                end{tikzpicture}

                                end{document}


                                enter image description here






                                share|improve this answer























                                • This is based on Image Magic right?
                                  – Christian Wolf
                                  Jun 5 '12 at 17:18










                                • @ChristianWolf: Right. I have now explained this in detail.
                                  – Daniel
                                  Jun 5 '12 at 19:00










                                • @ChristianWolf: Note also, that with this solution there is no need to disable externalization for the confidential images, as the generated image file itself is overwritten by the convert-generated one.
                                  – Daniel
                                  Jun 5 '12 at 22:14
















                                3














                                As you are using externalization anyway, you could also delegate the blackening to some external program that is invoked for the image to externalize via the external/system call key. The amazing thing (I have learned it from Andrew Stacey in the process of answering this question) about this key is that you can pass an arbitrary sequence of commands as long as the final output is a PDF.



                                In the following, I use ImageMagick's convert utility to replace the generated PDF by one with a simply filled canvas immediately after it has been generated by pdflatex. By defining own styles, the confidential mode can be activated/deactivated with tikzset globally or on a per-picture base.



                                documentclass[a4paper, 11pt]{article}

                                usepackage[T1]{fontenc}
                                usepackage{tikz}

                                % setup externalization
                                usetikzlibrary{external}
                                tikzexternalize
                                tikzset{
                                confidential tikz/.style={
                                external/system call={%
                                pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource";
                                convert "image".pdf -fill Tan -draw 'color 0,0 reset' "image".pdf}
                                },
                                public tikz/.style={
                                external/system call={%
                                pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource"}
                                }
                                }


                                tikzset{confidential tikz}

                                begin{document}

                                begin{tikzpicture}
                                draw[thick,rounded corners=8pt]
                                (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
                                end{tikzpicture}

                                tikzset{public tikz}

                                begin{tikzpicture}
                                draw[thick,rounded corners=8pt]
                                (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
                                end{tikzpicture}

                                end{document}


                                enter image description here






                                share|improve this answer























                                • This is based on Image Magic right?
                                  – Christian Wolf
                                  Jun 5 '12 at 17:18










                                • @ChristianWolf: Right. I have now explained this in detail.
                                  – Daniel
                                  Jun 5 '12 at 19:00










                                • @ChristianWolf: Note also, that with this solution there is no need to disable externalization for the confidential images, as the generated image file itself is overwritten by the convert-generated one.
                                  – Daniel
                                  Jun 5 '12 at 22:14














                                3












                                3








                                3






                                As you are using externalization anyway, you could also delegate the blackening to some external program that is invoked for the image to externalize via the external/system call key. The amazing thing (I have learned it from Andrew Stacey in the process of answering this question) about this key is that you can pass an arbitrary sequence of commands as long as the final output is a PDF.



                                In the following, I use ImageMagick's convert utility to replace the generated PDF by one with a simply filled canvas immediately after it has been generated by pdflatex. By defining own styles, the confidential mode can be activated/deactivated with tikzset globally or on a per-picture base.



                                documentclass[a4paper, 11pt]{article}

                                usepackage[T1]{fontenc}
                                usepackage{tikz}

                                % setup externalization
                                usetikzlibrary{external}
                                tikzexternalize
                                tikzset{
                                confidential tikz/.style={
                                external/system call={%
                                pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource";
                                convert "image".pdf -fill Tan -draw 'color 0,0 reset' "image".pdf}
                                },
                                public tikz/.style={
                                external/system call={%
                                pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource"}
                                }
                                }


                                tikzset{confidential tikz}

                                begin{document}

                                begin{tikzpicture}
                                draw[thick,rounded corners=8pt]
                                (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
                                end{tikzpicture}

                                tikzset{public tikz}

                                begin{tikzpicture}
                                draw[thick,rounded corners=8pt]
                                (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
                                end{tikzpicture}

                                end{document}


                                enter image description here






                                share|improve this answer














                                As you are using externalization anyway, you could also delegate the blackening to some external program that is invoked for the image to externalize via the external/system call key. The amazing thing (I have learned it from Andrew Stacey in the process of answering this question) about this key is that you can pass an arbitrary sequence of commands as long as the final output is a PDF.



                                In the following, I use ImageMagick's convert utility to replace the generated PDF by one with a simply filled canvas immediately after it has been generated by pdflatex. By defining own styles, the confidential mode can be activated/deactivated with tikzset globally or on a per-picture base.



                                documentclass[a4paper, 11pt]{article}

                                usepackage[T1]{fontenc}
                                usepackage{tikz}

                                % setup externalization
                                usetikzlibrary{external}
                                tikzexternalize
                                tikzset{
                                confidential tikz/.style={
                                external/system call={%
                                pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource";
                                convert "image".pdf -fill Tan -draw 'color 0,0 reset' "image".pdf}
                                },
                                public tikz/.style={
                                external/system call={%
                                pdflatex tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "image" "texsource"}
                                }
                                }


                                tikzset{confidential tikz}

                                begin{document}

                                begin{tikzpicture}
                                draw[thick,rounded corners=8pt]
                                (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
                                end{tikzpicture}

                                tikzset{public tikz}

                                begin{tikzpicture}
                                draw[thick,rounded corners=8pt]
                                (0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
                                end{tikzpicture}

                                end{document}


                                enter image description here







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Apr 13 '17 at 12:34









                                Community

                                1




                                1










                                answered Jun 5 '12 at 16:46









                                Daniel

                                29.1k670151




                                29.1k670151












                                • This is based on Image Magic right?
                                  – Christian Wolf
                                  Jun 5 '12 at 17:18










                                • @ChristianWolf: Right. I have now explained this in detail.
                                  – Daniel
                                  Jun 5 '12 at 19:00










                                • @ChristianWolf: Note also, that with this solution there is no need to disable externalization for the confidential images, as the generated image file itself is overwritten by the convert-generated one.
                                  – Daniel
                                  Jun 5 '12 at 22:14


















                                • This is based on Image Magic right?
                                  – Christian Wolf
                                  Jun 5 '12 at 17:18










                                • @ChristianWolf: Right. I have now explained this in detail.
                                  – Daniel
                                  Jun 5 '12 at 19:00










                                • @ChristianWolf: Note also, that with this solution there is no need to disable externalization for the confidential images, as the generated image file itself is overwritten by the convert-generated one.
                                  – Daniel
                                  Jun 5 '12 at 22:14
















                                This is based on Image Magic right?
                                – Christian Wolf
                                Jun 5 '12 at 17:18




                                This is based on Image Magic right?
                                – Christian Wolf
                                Jun 5 '12 at 17:18












                                @ChristianWolf: Right. I have now explained this in detail.
                                – Daniel
                                Jun 5 '12 at 19:00




                                @ChristianWolf: Right. I have now explained this in detail.
                                – Daniel
                                Jun 5 '12 at 19:00












                                @ChristianWolf: Note also, that with this solution there is no need to disable externalization for the confidential images, as the generated image file itself is overwritten by the convert-generated one.
                                – Daniel
                                Jun 5 '12 at 22:14




                                @ChristianWolf: Note also, that with this solution there is no need to disable externalization for the confidential images, as the generated image file itself is overwritten by the convert-generated one.
                                – Daniel
                                Jun 5 '12 at 22:14


















                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f58649%2fhow-to-black-out-a-figure-for-confidential-reasons%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                サソリ

                                広島県道265号伴広島線

                                Setup Asymptote in Texstudio