From 06b49295b1b096e8d264acce852cf9deabbd01a4 Mon Sep 17 00:00:00 2001 From: milde Date: Mon, 10 Nov 2014 16:03:33 +0000 Subject: [PATCH] Fix [ 262 ] Use ``\\\\linewidth`` instead of ``\\\\textwidth`` for figures, admonitions and docinfo. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7775 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/HISTORY.txt | 6 +++++- docutils/docutils/writers/latex2e/__init__.py | 10 +++++----- .../test/functional/expected/standalone_rst_latex.tex | 18 +++++++++--------- .../test/functional/expected/standalone_rst_xetex.tex | 18 +++++++++--------- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 50ae5530c..266d7f40a 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -16,6 +16,10 @@ Changes Since 0.12 ================== +* docutils/writers/latex2e/__init__.py + + - Fix [ 262 ] Use ``\linewidth`` instead of ``\textwidth`` for figures, + admonitions and docinfo. Release 0.12 (2014-07-06) ========================= @@ -26,7 +30,7 @@ Release 0.12 (2014-07-06) * docutils/parsers/rst/directives/images.py - - Fix [258] figwidth="image" generates unitless width value. + - Fix [ 258 ] figwidth="image" generates unitless width value. * docutils/parsers/rst/states.py diff --git a/docutils/docutils/writers/latex2e/__init__.py b/docutils/docutils/writers/latex2e/__init__.py index 8187cae6a..5220d8003 100644 --- a/docutils/docutils/writers/latex2e/__init__.py +++ b/docutils/docutils/writers/latex2e/__init__.py @@ -490,7 +490,7 @@ PreambleCmds.admonition = r""" \csname DUadmonition#1\endcsname{#2}% \else \begin{center} - \fbox{\parbox{0.9\textwidth}{#2}} + \fbox{\parbox{0.9\linewidth}{#2}} \end{center} \fi }""" @@ -509,7 +509,7 @@ PreambleCmds.color = r"""\usepackage{color}""" PreambleCmds.docinfo = r""" % docinfo (width of docinfo table) -\DUprovidelength{\DUdocinfowidth}{0.9\textwidth}""" +\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}""" # PreambleCmds.docinfo._depends = 'providelength' PreambleCmds.dedication = r""" @@ -650,7 +650,7 @@ PreambleCmds.sidebar = r""" % sidebar (text outside the main text flow) \providecommand{\DUsidebar}[2][class-arg]{% \begin{center} - \colorbox[gray]{0.80}{\parbox{0.9\textwidth}{#2}} + \colorbox[gray]{0.80}{\parbox{0.9\linewidth}{#2}} \end{center} }""" @@ -2139,7 +2139,7 @@ class LaTeXTranslator(nodes.NodeVisitor): # for "inner alignment" use LaTeX default alignment (similar to HTML) alignment = node.attributes.get('align', 'center') if alignment != 'center': - # The LaTeX "figure" environment always uses the full textwidth, + # The LaTeX "figure" environment always uses the full linewidth, # so "outer alignment" is ignored. Just write a comment. # TODO: use the wrapfigure environment? self.out.append('\n\\begin{figure} %% align = "%s"\n' % alignment) @@ -2306,7 +2306,7 @@ class LaTeXTranslator(nodes.NodeVisitor): 'middle': (r'\raisebox{-0.5\height}{', '}'), 'top': (r'\raisebox{-\height}{', '}'), # block level images: - 'center': (r'\noindent\makebox[\textwidth][c]{', '}'), + 'center': (r'\noindent\makebox[\linewidth][c]{', '}'), 'left': (r'\noindent{', r'\hfill}'), 'right': (r'\noindent{\hfill', '}'),} if 'align' in attrs: diff --git a/docutils/test/functional/expected/standalone_rst_latex.tex b/docutils/test/functional/expected/standalone_rst_latex.tex index e679dc0e9..a5457dceb 100644 --- a/docutils/test/functional/expected/standalone_rst_latex.tex +++ b/docutils/test/functional/expected/standalone_rst_latex.tex @@ -48,7 +48,7 @@ \csname DUadmonition#1\endcsname{#2}% \else \begin{center} - \fbox{\parbox{0.9\textwidth}{#2}} + \fbox{\parbox{0.9\linewidth}{#2}} \end{center} \fi } @@ -62,7 +62,7 @@ \providecommand{\DUtopicdedication}[1]{\begin{center}#1\end{center}} % docinfo (width of docinfo table) -\DUprovidelength{\DUdocinfowidth}{0.9\textwidth} +\DUprovidelength{\DUdocinfowidth}{0.9\linewidth} % subtitle (in document title) \providecommand*{\DUdocumentsubtitle}[1]{{\large #1}} @@ -146,7 +146,7 @@ % sidebar (text outside the main text flow) \providecommand{\DUsidebar}[2][class-arg]{% \begin{center} - \colorbox[gray]{0.80}{\parbox{0.9\textwidth}{#2}} + \colorbox[gray]{0.80}{\parbox{0.9\linewidth}{#2}} \end{center} } @@ -895,7 +895,7 @@ Image with multiple IDs: A centered image: -\noindent\makebox[\textwidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}} A left-aligned image: @@ -938,7 +938,7 @@ media, figures might float to a different position if this helps the page layout. \begin{figure} -\noindent\makebox[\textwidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}} +\noindent\makebox[\linewidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}} \caption{Plaintext markup syntax and parser system.} \begin{DUlegend} \setlength{\DUtablewidth}{\linewidth} @@ -971,7 +971,7 @@ This paragraph is also part of the legend. A left-aligned figure: \begin{figure} % align = "left" -\noindent\makebox[\textwidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}} \caption{This is the caption.} \begin{DUlegend} This is the legend. @@ -988,7 +988,7 @@ rendering software used. A centered figure: \begin{figure} -\noindent\makebox[\textwidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}} \caption{This is the caption.} \begin{DUlegend} This is the legend. @@ -1005,7 +1005,7 @@ rendering software used. A right-aligned figure: \begin{figure} % align = "right" -\noindent\makebox[\textwidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics[width=40px]{../../../docs/user/rst/images/biohazard.png}} \caption{This is the caption.} \begin{DUlegend} This is the legend. @@ -2386,7 +2386,7 @@ None \begin{figure} \phantomsection\label{figure-label} -\noindent\makebox[\textwidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}} \caption{Figure with % \label{hypertarget-in-figure-caption}hypertarget in figure caption.} \begin{DUlegend} diff --git a/docutils/test/functional/expected/standalone_rst_xetex.tex b/docutils/test/functional/expected/standalone_rst_xetex.tex index a54b6b0cd..96fc21846 100644 --- a/docutils/test/functional/expected/standalone_rst_xetex.tex +++ b/docutils/test/functional/expected/standalone_rst_xetex.tex @@ -44,7 +44,7 @@ \csname DUadmonition#1\endcsname{#2}% \else \begin{center} - \fbox{\parbox{0.9\textwidth}{#2}} + \fbox{\parbox{0.9\linewidth}{#2}} \end{center} \fi } @@ -58,7 +58,7 @@ \providecommand{\DUtopicdedication}[1]{\begin{center}#1\end{center}} % docinfo (width of docinfo table) -\DUprovidelength{\DUdocinfowidth}{0.9\textwidth} +\DUprovidelength{\DUdocinfowidth}{0.9\linewidth} % subtitle (in document title) \providecommand*{\DUdocumentsubtitle}[1]{{\large #1}} @@ -145,7 +145,7 @@ % sidebar (text outside the main text flow) \providecommand{\DUsidebar}[2][class-arg]{% \begin{center} - \colorbox[gray]{0.80}{\parbox{0.9\textwidth}{#2}} + \colorbox[gray]{0.80}{\parbox{0.9\linewidth}{#2}} \end{center} } @@ -894,7 +894,7 @@ Image with multiple IDs: A centered image: -\noindent\makebox[\textwidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}} A left-aligned image: @@ -937,7 +937,7 @@ media, figures might float to a different position if this helps the page layout. \begin{figure} -\noindent\makebox[\textwidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}} +\noindent\makebox[\linewidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}} \caption{Plaintext markup syntax and parser system.} \begin{DUlegend} \setlength{\DUtablewidth}{\linewidth} @@ -970,7 +970,7 @@ This paragraph is also part of the legend. A left-aligned figure: \begin{figure} % align = "left" -\noindent\makebox[\textwidth][c]{\includegraphics[width=40\pdfpxdimen]{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics[width=40\pdfpxdimen]{../../../docs/user/rst/images/biohazard.png}} \caption{This is the caption.} \begin{DUlegend} This is the legend. @@ -987,7 +987,7 @@ rendering software used. A centered figure: \begin{figure} -\noindent\makebox[\textwidth][c]{\includegraphics[width=40\pdfpxdimen]{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics[width=40\pdfpxdimen]{../../../docs/user/rst/images/biohazard.png}} \caption{This is the caption.} \begin{DUlegend} This is the legend. @@ -1004,7 +1004,7 @@ rendering software used. A right-aligned figure: \begin{figure} % align = "right" -\noindent\makebox[\textwidth][c]{\includegraphics[width=40\pdfpxdimen]{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics[width=40\pdfpxdimen]{../../../docs/user/rst/images/biohazard.png}} \caption{This is the caption.} \begin{DUlegend} This is the legend. @@ -2154,7 +2154,7 @@ None \begin{figure} \phantomsection\label{figure-label} -\noindent\makebox[\textwidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}} +\noindent\makebox[\linewidth][c]{\includegraphics{../../../docs/user/rst/images/biohazard.png}} \caption{Figure with % \label{hypertarget-in-figure-caption}hypertarget in figure caption.} \begin{DUlegend} -- 2.11.4.GIT