Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set an article to landscape? #292

Open
haferburg opened this issue Sep 14, 2021 · 1 comment
Open

How to set an article to landscape? #292

haferburg opened this issue Sep 14, 2021 · 1 comment

Comments

@haferburg
Copy link

haferburg commented Sep 14, 2021

I found this http://www.mos6581.org/rinohtype/master/basicstyling.html#configuring-a-template
but didn't find it particularly helpful. What I would expect here is an explanation of how to find information. E. g. it says

The Article template defines three parts: title, front_matter and contents.

What I'm missing here is an explanation along this line: "The template defines different parts, which are referenced by subsections in the template. The available parts can be found here..." Why is the correct string "[contents]"? How do I know that page_number_format option goes into the "[contents]" section? Or vice versa, how would I know that the [contents] section even has this option? Help me to help myself. It's about discoverability.

I found this
http://www.mos6581.org/rinohtype/master/api/template.html#rinoh.template.PageTemplate.page_orientation
but it doesn't explain how to use it. The section header reads

Page Templates
The document templates make use of page templates

I don't even understand what that means. How does that help the reader?


I tried this

template = article
page_orientation = landscape

which results in an unhandled exception

  File "c:\users\ahaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\rinoh\attribute.py", line 309, in attribute_type
    return cls.attribute_definition(name).accepted_type
  File "c:\users\ahaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\rinoh\attribute.py", line 304, in attribute_definition
    raise KeyError(name)
KeyError: 'page_orientation'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\ahaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\ahaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\AHaferbu\.pyenv\pyenv-win\versions\3.9.6\Scripts\rinoh.exe\__main__.py", line 7, in <module>
  File "c:\users\ahaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\rinoh\__main__.py", line 277, in main
    template_cfg['base'] = TemplateConfigurationFile(args.template,
  File "c:\users\ahaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\rinoh\attribute.py", line 488, in __init__
Using the reStructuredText frontend [built-in]
    super().__init__(name, base=base, source=source, **options)
  File "c:\users\ahaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\rinoh\template.py", line 513, in __init__
    options[attr] = self._validate_attribute(self.template, attr, val)
  File "c:\users\ahaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\rinoh\attribute.py", line 408, in _validate_attribute
    attribute_type = attr_dict.attribute_type(name)
  File "c:\users\ahaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\rinoh\attribute.py", line 311, in attribute_type
    raise TypeError('{} is not a supported attribute for {}'
TypeError: page_orientation is not a supported attribute for Article

What do I do?

@brechtm
Copy link
Owner

brechtm commented Oct 1, 2021

Thanks for taking the time to point out these issues with the documentation. I am sure there is massive room for improvement, which could in turn help adoption of rinohtype. Unfortunately, I'm lacking the time to do much work on rinohtype lately.

For this particular issue, please look at the example template configuration included here:

[TEMPLATE_CONFIGURATION]
name = my article configuration
template = article

parts =
    title
    ;front_matter
    contents
stylesheet = sphinx_base14
language = fr
abstract_location = title

...

[title]
page_number_format = lowercase roman
end_at_page = left

[contents]
page_number_format = number

[title_page]
top_margin = 2cm

A document consists of document parts. Each part has an associated page template. [title] and [contents] configure the document part templates. [title_page] corresponds to the page template for the title part. As you discovered, page_orientation is a page template property, so you need to place it under [title_page] or [contents_page].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants