Skip to content

Commit

Permalink
Rename display_page_number to simple_page_number
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Aug 24, 2016
1 parent 1afd7cc commit 155217d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
5 changes: 2 additions & 3 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ Added
uncertain quantities.
- Added `.PageStyle` class to support the creation of various page styles. In
addition to this class `.Head` and `.Foot` were added for creating unique
headers and footers within the page styles.
- Added a display_page_number method inside `~.Head` to return a string which
displays the page number in latex.
headers and footers within the page styles. A `.simple_page_number` function
was also added for easy displaying of a simple page number.
- Added a new type of container `.ContainerCommand` for supporting commands
with data.
- Added new options to the `.Document` constructor: ``geometry_options`` (a
Expand Down
4 changes: 2 additions & 2 deletions examples/complex_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from pylatex import Document, PageStyle, Head, Foot, MiniPage, \
StandAloneGraphic, MultiColumn, Tabu, LongTabu, LargeText, MediumText, \
LineBreak, NewPage, Tabularx, TextColor
LineBreak, NewPage, Tabularx, TextColor, simple_page_number
from pylatex.utils import bold, NoEscape


Expand Down Expand Up @@ -70,7 +70,7 @@ def generate_unique():
pos='t', align='r')
document_details.append("1000")
document_details.append(LineBreak())
document_details.append(Head.display_page_number())
document_details.append(simple_page_number())

footer_table.add_row([branch_address, branch_address,
branch_address, document_details])
Expand Down
4 changes: 2 additions & 2 deletions examples/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# begin-doc-include
from pylatex import Document, PageStyle, Head, MiniPage, Foot, LargeText, \
MediumText, LineBreak
MediumText, LineBreak, simple_page_number
from pylatex.utils import bold


Expand All @@ -29,7 +29,7 @@ def generate_header():
header.append("Company")
# Create right header
with header.create(Head("R")):
header.append(Head.display_page_number())
header.append(simple_page_number())
# Create left footer
with header.create(Foot("L")):
header.append("Left Footer")
Expand Down
2 changes: 1 addition & 1 deletion pylatex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
from .base_classes import Command, UnsafeCommand
from .utils import NoEscape, escape_latex, _latex_item_to_string
from .errors import TableRowSizeError
from .headfoot import PageStyle, Head, Foot
from .headfoot import PageStyle, Head, Foot, simple_page_number
from .position import Center, FlushLeft, FlushRight, MiniPage, TextBlock
24 changes: 12 additions & 12 deletions pylatex/headfoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ def change_thickness(self, element, thickness):
NoEscape(r"\footrulewidth"), str(thickness) + 'pt']))


def simple_page_number():
"""Get a string containing commands to display the page number.
Returns
-------
str
The latex string that displays the page number
"""

return NoEscape(r'Page \thepage\ of \pageref{LastPage}')


class Head(ContainerCommand):
r"""Allows the creation of headers."""

Expand All @@ -86,18 +98,6 @@ def __init__(self, position=None, *, data=None):

super().__init__(data=data, options=position)

@staticmethod
def display_page_number():
"""Get the string that displays the page number.
Returns
-------
str
The latex string that displays the page number
"""

return NoEscape(r'Page \thepage\ of \pageref{LastPage}')


class Foot(Head):
r"""Allows the creation of footers."""
Expand Down

0 comments on commit 155217d

Please sign in to comment.