LaTeX forum ⇒ Text FormattingManaging censorship by class of document?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
ygini
Posts: 2
Joined: Mon Aug 08, 2016 6:45 pm

Managing censorship by class of document?

Postby ygini » Mon Aug 08, 2016 6:57 pm

Hello

I'm using LaTeX to write confidential documents, for those document I use the traffic light protocol (https://www.us-cert.gov/tlp) manage by 4 different custom classes used to add color and sharing instruction in header and footnote.

Those documents are used for many purpose and I would like to be able to censor some informations of the document based on the current traffic light.

I've found multiple solutions on different forum but nothing who fit my needs for now.

My main problem is, the content to protect can be in a middle of a paragraph or in a table cell, It can be regular text, \verb|| text, or even \url{} text.

My main idea was to use my custom classes to create and renew custom commands (like \GreenSecret, \AmberSecret, \RedSecret) to specify when a block of text must be redacted or not.

What do you think? What would be the best solution and implementation?

I'm new to this level of LaTeX customization so I don't really know what to look as a good source of inspiration. I've only written custom classes for custom look, nothing more.
Last edited by cgnieder on Wed Sep 21, 2016 8:08 pm, edited 1 time in total.
Reason: added inline code markup

Tags:

SteWo
Posts: 1
Joined: Tue Sep 20, 2016 3:07 pm

Postby SteWo » Tue Sep 20, 2016 3:31 pm

Hi ygini!

I never had to deal with such a requirement but I would take a look at the ifthenelse-package: Define via \setboolean four 'levels' as boolean variables and use them nested. E.g. like so:
  1. \setboolean level0 true
  2. \setboolean level1 true
  3. \setboolean level2 false
  4. \setboolean level3 false
  5.  
  6. ...
  7.  
  8. \ifthenelse level0
  9. {some general text and within:
  10. \ifthenelse level1
  11. {some lightly confidential text and within
  12. \ifthenelse level2
  13. {some really confidential text and within
  14. \ifthenelse level3
  15. {area-51 information}
  16. }
  17. }
  18. }


Got the idea? This example's output should only show the text up to what may be shown for levels 0 and 1 but not levels 2 and 3. As this is not actual code you might want to study the relevant documentation.

Hope I could help.

Best
Last edited by cgnieder on Wed Sep 21, 2016 8:09 pm, edited 1 time in total.
Reason: added code markup

User avatar
cgnieder
Site Moderator
Posts: 1974
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Wed Sep 21, 2016 8:39 pm

Here is some idea. I hope the code is self-explanatory. Feel free to ask if it isn't:

  1. \documentclass{article}
  2.  
  3. \usepackage{etoolbox}
  4.  
  5. % a counter for the current level of secrecy:
  6. \newcounter{secretlevel}
  7.  
  8. % a macro for internal book-keeping:
  9. \newcommand*\secretlevels{}
  10.  
  11. % error message for wrong level names (thinking of typos):
  12. \newcommand*\unknownsecretlevel[1]{%
  13. \ClassError{myclass}{unknown secret level}{The secret level `#1' is unknown}%
  14. }
  15.  
  16. % a check if a level is defined:
  17. \newcommand\ifsecretlevelexist[3]{\ifinlist{#1}{\secretlevels}{#2}{#3}}
  18.  
  19. % a check for the current level:
  20. \newcommand\ifsecretlevel[3]{%
  21. \ifnumless{\csuse{level-#1}}{\value{secretlevel}+1}
  22. {#2}
  23. {#3}%
  24. }
  25.  
  26. % setting a certain level:
  27. \newcommand*\setsecretlevel[1]{%
  28. \ifsecretlevelexist{#1}
  29. {\setcounter{secretlevel}{\csuse{level-#1}}}
  30. {\unknownsecretlevel{#1}}%
  31. }
  32.  
  33. % define levels:
  34. \newcommand*\newsecretlevel[2]{%
  35. \listadd\secretlevels{#1}%
  36. \csdef{level-#1}{#2}%
  37. }
  38.  
  39. % print depending on the current level and the specification:
  40. \newcommand*\secret[2]{%
  41. \ifsecretlevelexist{#1}
  42. {\ifsecretlevel{#1}{#2}{}}
  43. {\unknownsecretlevel{#1}}%
  44. }
  45.  
  46. % define some levels:
  47. \newsecretlevel{Green}{0}
  48. \newsecretlevel{Amber}{1}
  49. \newsecretlevel{Red}{2}
  50.  
  51. % set default level:
  52. \setsecretlevel{Green}
  53.  
  54. \begin{document}
  55.  
  56. \section{Level Green: we only see green}
  57. \secret{Green}{I am green} \par
  58. \secret{Amber}{I am amber} \par
  59. \secret{Red}{I am red}
  60.  
  61. \section{Level Amber: we see green and amber}
  62. \setsecretlevel{Amber}
  63. \secret{Green}{I am green} \par
  64. \secret{Amber}{I am amber} \par
  65. \secret{Red}{I am red}
  66.  
  67. \section{Level Red: we see green, amber and red}
  68. \setsecretlevel{Red}
  69. \secret{Green}{I am green} \par
  70. \secret{Amber}{I am amber} \par
  71. \secret{Red}{I am red}
  72.  
  73. % gives an error:
  74. % \secret{Purple}{I am purple}
  75.  
  76. \end{document}


Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 2 guests