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

Question #31

Closed
Starow opened this issue Jan 27, 2015 · 5 comments
Closed

Question #31

Starow opened this issue Jan 27, 2015 · 5 comments
Labels

Comments

@Starow
Copy link

Starow commented Jan 27, 2015

Hello,
I read your introduction/presentation and you're saying:
"Everything else you want you can still add to the document by adding LaTeX formatted strings to the container class you want it to be in."
Could you provide an example ?

I would like to add a Tittle page at the very beggining of a document created with PyLaTeX.
Is it possible to add directly "raw" latex command such as \newpage or a group of these kind of lines with PyLaTeX ?
Thank you in advance! :)

@JelteF
Copy link
Owner

JelteF commented Jan 27, 2015

Yes, any object inherits from one of the container baseclasses can also contain "raw" latex strings.
You can just do:

doc = Document()
doc.append(r'\newpage')
doc.append('This is on a new page')

This is also why you should always escape user supplied strings using the utils function.

In some cases it might be easier to use the Command class. This is mostly the case when your commands need arguments that aren't hard coded.
If you need a specific environment (like enumerate wiht a begin and end command) it might be easiest to inherit LatexNamedContainer, since that does that for you and you can use the with syntax that way.

@Starow
Copy link
Author

Starow commented Jan 27, 2015

Thank you for these infos and the fast reply!
I passed everything inside some r'text' strings and it works :)

@Starow Starow closed this as completed Jan 27, 2015
@JelteF
Copy link
Owner

JelteF commented Jan 27, 2015

No problem. BTW the r before r'text' is just so you don't have to escape all the backslashes its something that is built in to python.

@LydiaF
Copy link

LydiaF commented May 30, 2016

Thank you for this info :)

@jdonkervliet
Copy link

Note that this no longer works. You should use wrap your raw latex in NoEscape or use the Command class in case you want to insert a command.

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

No branches or pull requests

4 participants