Hi,
On Saturday, 24 November 2012 08:09:49 UTC+1, sree wrote:
>
> I am a sphinx-newbie working on user manual documentation. I am able to
> generate notes using the sphinx directive ".. notes::" The notes in html
> file has background color but the PDF generated from tex file does not have
> the background color.
>
> How can I automatically generate the background color in notes for the
> Latex PDF using Sphinx?
>
> Thank you!
>
To do a similar thing (for the topic environment), I had to modify the
files /usr/share/sphinx/texinputs/sphinx.sty (1) and
/usr/share/pyshared/sphinx/writers/latex.py (2).
Not difficult, but some care is required. Backup the original files so you
can revert to them if something fails.
In (1), you should first change the type of note from lightbox to heavybox
(lightboxes do not support backgound). Search for
\newcommand{\py@noticestart@note}{\py@lightbox}
\newcommand{\py@noticeend@note}{\py@endlightbox}
and modify to
\newcommand{\py@noticestart@note}{\py@heavybox}
\newcommand{\py@noticeend@note}{\py@endheavybox}
Then you should modify the \py@heavybox and \py@endheavybox} into a latex
environment that support colors (for topic I used mdframed, which is very
flexible
Then, in (2), locate the lines that define the creation of the latex code
for notes:
visit_note = _make_visit_admonition('note')
depart_note = _depart_named_admonition
which redirect you to:
def _make_visit_admonition(name):
def visit_admonition(self, node):
self.body.append(u'\n\\begin{notice}{%s}{%s:}' %
(name, admonitionlabels[name]))
return visit_admonition
def _depart_named_admonition(self, node):
self.body.append('\\end{notice}\n')
and add here suitable commands for changing the background. If you use
mdframed, here's how I modified topic, perhaps it gives you some more hint.
In (1)
\definecolor{topicshade}{rgb}{0.95,0.95,1}
\newenvironment{topic}
{\begin{mdframed}
[skipabove=6pt,
usetwoside=true,
topline=false,
bottomline=false,
rightline=false,
leftline=true,
linewidth=2,
linecolor=TitleColor,
backgroundcolor=topicshade
rightmargin=0pt,
innerrightmargin=0pt,
innertopmargin=0pt,
innerbottommargin=0pt,
innerleftmargin=6pt,
needspace=10pt]
}
{\end{mdframed}}
in (2)
# def visit_topic(self, node):
# self.body.append('\\setbox0\\vbox{\n'
# '\\begin{minipage}{0.95\\linewidth}\n')
# def depart_topic(self, node):
# self.body.append('\\end{minipage}}\n'
# '\\begin{center}\\setlength{\\fboxsep}{5pt}'
# '\\shadowbox{\\box0}\\end{center}\n')
def visit_topic(self,node):
self.body.append('\\begin{topic}\n')
def depart_topic(self,node):
self.body.append('\\end{topic}')
Remember also to add \RequirePackage{mdframed} at the beginning of file (1).
I do not know if there's an easier way, but in case, please let me know! :)
Hope this helps,
Stefano
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/sphinx-users?hl=en.