docs-rst: improve output for .. notes:: on LaTeX
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 16 Aug 2016 16:25:38 +0000 (13:25 -0300)
committerJonathan Corbet <corbet@lwn.net>
Thu, 18 Aug 2016 22:41:42 +0000 (16:41 -0600)
The output for those notes are bad in pdf, as they're not
in a box with a different color. Also, it causes the output
to not build if the note is inside a table.

Change its implementation to avoid the above troubles.

The logic there came from:
https://stackoverflow.com/questions/606746/how-to-customize-an-existing-latex-environment-without-interfering-with-other-en

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Documentation/conf.py

index 38b240073336db8fab6d0d92c2e41923ad5b4c2e..429183a03b921e4046fde4d45cd345d5f35bb768 100644 (file)
@@ -258,6 +258,29 @@ latex_elements = {
     'preamble': '''
         % Allow generate some pages in landscape
         \\usepackage{lscape}
+
+        % Put notes in gray color and let them be inside a table
+
+        \\definecolor{MyGray}{rgb}{0.80,0.80,0.80}
+
+        \\makeatletter\\newenvironment{graybox}{%
+           \\begin{lrbox}{\\@tempboxa}\\begin{minipage}{\\columnwidth}}{\\end{minipage}\\end{lrbox}%
+           \\colorbox{MyGray}{\\usebox{\\@tempboxa}}
+        }\\makeatother
+
+        \\makeatletter
+        \\renewenvironment{notice}[2]{
+          \\begin{graybox}
+          \\bf\\it
+          \\def\\py@noticetype{#1}
+          \\par\\strong{#2}
+          \\csname py@noticestart@#1\\endcsname
+        }
+       {
+          \\csname py@noticeend@\\py@noticetype\\endcsname
+          \\end{graybox}
+        }
+       \\makeatother
      '''
 }