Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(13)  |  Call(7)  |  Derive(0)  |  Import(6)
In LaTeX, captions are used within floating environmonts (such as
"table" or "figure").
Since we generate LaTeX automatically we are usually not using floating
environments so that LaTeX does not reposition images and tables.
Because of that we cannot use the standard \caption command, we need
to do it manually.

This helper function generates the LaTeX code for placing a caption
outside a floating environment.
(more...)

        def generate_manual_caption(caption, environment, show_in_index=True):
    """In LaTeX, captions are used within floating environmonts (such as
    "table" or "figure").
    Since we generate LaTeX automatically we are usually not using floating
    environments so that LaTeX does not reposition images and tables.
    Because of that we cannot use the standard \caption command, we need
    to do it manually.

    This helper function generates the LaTeX code for placing a caption
    outside a floating environment.

    Arguments:
    caption -- The caption text as LaTeX.
    enviroment -- The type of environment (either "table" or "figure").
    """

    if not caption:
        return ''

    if environment not in ENVIRONMENTS.keys():
        raise ValueError('Environment must be one of "%s". Got "%s".' % (
                '", "'.join(ENVIRONMENTS.keys()), environment))

    env = ENVIRONMENTS[environment]
    label = translate(env['label'], context=getSite().REQUEST).encode('utf-8')

    latex = [r'\begin{center}']

    if show_in_index:
        latex.extend([
                r'\addtocounter{%s}{1}' % env['counter'],

                r'\addcontentsline{%s}{%s}{' % (
                    env['index'], env['counter']) +
                r'\protect\numberline ' +
                r'{\thechapter.\arabic{%s}}' % env['counter'] +
                r'{\ignorespaces %s}' % caption +
                r'}',

                r'%s \thechapter.\arabic{%s}: %s' % (
                    label, env['counter'], caption),
                ])

    else:
        latex.append(caption)

    latex.extend([
            r'\end{center}',
            r'',
            ])

    return '\n'.join(latex)
        


src/f/t/ftw.pdfgenerator-1.3.0/ftw/pdfgenerator/html2latex/subconverters/table.py   ftw.pdfgenerator(Download)
from BeautifulSoup import BeautifulSoup
from ftw.pdfgenerator import interfaces
from ftw.pdfgenerator.html2latex import subconverter
from ftw.pdfgenerator.html2latex import wrapper
from ftw.pdfgenerator.html2latex.utils import generate_manual_caption
        show_in_index = 'notListed' not in self.get_css_classes()
 
        latex = generate_manual_caption(caption, 'table',
                                        show_in_index=show_in_index)
 

src/f/t/ftw.book-2.2.20/ftw/book/latex/utils.py   ftw.book(Download)
from Acquisition import aq_inner, aq_parent
from Products.ATContentTypes.lib.imagetransform import ATCTImageTransform
from ftw.book.interfaces import IBook
from ftw.pdfgenerator.html2latex.utils import generate_manual_caption
from ftw.pdfgenerator.templating import MakoTemplating
            return '%s\n%s' % (
                latex,
                generate_manual_caption(caption, 'figure'))
 
    def _extend_latex_with_alignment(self, latex, alignment):

src/f/t/ftw.pdfgenerator-1.3.0/ftw/pdfgenerator/tests/test_html2latex_utils.py   ftw.pdfgenerator(Download)
from ftw.pdfgenerator.html2latex.utils import generate_manual_caption
from ftw.pdfgenerator.testing import ZCML_WITH_SITE_LAYER
from ftw.testing import MockTestCase
 
 
    def test_wrong_index(self):
        with self.assertRaises(ValueError) as cm:
            generate_manual_caption('foo', 'wrong')
 
        self.assertEqual(
            str(cm.exception),
            'Environment must be one of "table", "figure". Got "wrong".')
 
    def test_table_caption(self):
        latex = generate_manual_caption('The Caption', 'table')
    def test_figure_caption(self):
        latex = generate_manual_caption('The Caption', 'figure')
        self.assertIn(r'\addtocounter{figure}{1}', latex)
        self.assertIn(r'\addcontentsline{lof}{figure}', latex)
        self.assertIn(r'\ignorespaces The Caption', latex)
        self.assertIn(r'Figure \thechapter.\arabic{figure}: The Caption',
                      latex)
 
    def test_not_listed_table_caption(self):
        latex = generate_manual_caption('The Caption', 'table',

src/f/t/ftwbook.graphicblock-2.2.2/ftwbook/graphicblock/latex/graphicblock.py   ftwbook.graphicblock(Download)
from ftw.pdfgenerator.html2latex.utils import generate_manual_caption
from ftw.pdfgenerator.view import MakoLaTeXView
from ftwbook.graphicblock.interfaces import IGraphicBlock
from zope.component import adapts
from zope.interface import Interface

src/f/t/ftw.book-2.2.20/ftw/book/tests/test_latex_utils.py   ftw.book(Download)
from ftw.book.latex.utils import get_latex_heading
from ftw.book.latex.utils import get_raw_image_data
from ftw.pdfgenerator.html2latex.utils import generate_manual_caption
from ftw.pdfgenerator.interfaces import ILaTeXLayout
from ftw.testing import MockTestCase

src/f/t/ftw.book-2.2.20/ftw/book/tests/test_image_latex_converter.py   ftw.book(Download)
from Products.ATContentTypes.interfaces.image import IATImage
from ftw.book.testing import LATEX_ZCML_LAYER
from ftw.pdfgenerator.html2latex.utils import generate_manual_caption
from ftw.pdfgenerator.interfaces import IHTML2LaTeXConverter
from ftw.pdfgenerator.interfaces import ILaTeXLayout