Skip to content

Commit

Permalink
Rename add_variable to set_variable and explain it in more detail
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Aug 24, 2016
1 parent f3e63ac commit 87a812d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 4 additions & 3 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ Added
list of options for the geometry package), ``document_options`` (a list of
options to place in the document class), ``indents`` (an option to select
whether the documents elements are indented), ``page_numbers`` (an option to
choose whether to use the lastpage package or not), ``font_size`` (the font
size to set at the beggining of the document).
choose whether to use page numbers or not), ``font_size`` (the font size to
set at the beggining of the document).
- Added several new methods to the `.Document`: ``change_page_style``,
``change_document_style``, ``add_color``, ``change_length``.
``change_document_style``, ``add_color``, ``change_length``,
``set_variable``.
- Added a new `.position` package with the following classes: `.Center` (an
environment with centered content), `.FlushLeft` (an environment with left
aligned content), `.FlushRight` (an environment with right aligned content),
Expand Down
8 changes: 6 additions & 2 deletions pylatex/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,12 @@ def change_length(self, parameter, value):
self.preamble.append(UnsafeCommand('setlength',
arguments=[parameter, value]))

def add_variable(self, name, value):
"""Add a variable which can be used inside the document.
def set_variable(self, name, value):
r"""Add a variable which can be used inside the document.
Variables are defined before the preamble. If a variable with that name
has already been set, the new value will override it for future uses.
This is done by appending ``\renewcommand`` to the document.
Args
----
Expand Down
3 changes: 2 additions & 1 deletion tests/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def test_document():
doc.change_document_style(style="plain")
doc.add_color(name="lightgray", model="gray", description="0.6")
doc.add_color(name="abitless", model="gray", description="0.8")
doc.add_variable(name="myVar", value="1234")
doc.set_variable(name="myVar", value="1234")
doc.set_variable(name="myVar", value="1234")
doc.change_length(parameter=r"\headheight", value="0.5in")

doc.generate_tex(filepath='')
Expand Down

0 comments on commit 87a812d

Please sign in to comment.