question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No example to add indented text after doc creation, except lorem epsum example

See original GitHub issue

There is no more examples that explains how to indent our text blocks.

One of the way is

doc = Document(data=NoEscape(lorem))

that you can find at https://jeltef.github.io/PyLaTeX/latest/examples/config.html.

But what if I want to add the indented text after doc creation using

doc = Document() statement

So that beautiful letterhead pdf documents could be created.

The PyLaTex doc is excellent but I am not finding any example related to the above issue.

I am not sure whether there is any way to do this(already present in the documentation).

I tried a lot but failed. Suggest me any example please.

What I want is I want to create letterhead documents something like in this https://www.latextemplates.com/cat/formal-letters.

I am able to add logo, right header text etc. but I am unable to indent text blocks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JelteFcommented, Feb 25, 2018

And regarding the import error. You should do from pylatex.section import Paragraph. Apparently it’s not exported in the main module.

0reactions
hygullcommented, Feb 27, 2018

Thanks for your appreciable help @JelteF .

I am trying to use font_size = "10pt" with Document() constructor but it is failing to affect the font size.

ISSUSES:-

  • if I am using doc.create(Paragraph("")) then it is adding space at the beginning of each paragraph.

  • doc.content_separator = "\n\n\n\n" , doc.content_separator = "\n\n", doc.content_separator = "\t\t" all are producing the same pdf.

CODE SNIPPET:-

  doc = Document("paragraph", indent=False, geometry_options=geometry_options, \
        font_size="40pt", document_options="a4paper");

Just check font_size in the above code snippet.

And suggest me the way to overcome these issues. You can also check my complete code snippet below.

from pylatex import Document, LargeText
from pylatex.section import Paragraph;
from pylatex.utils import bold

geometry_options = {
	"head": "1pt",
	"margin": "0.5in",
	"bottom": "0.5in",
	"includeheadfoot": True
}

doc = Document("paragraph", indent=False, geometry_options=geometry_options, \
	font_size="40pt", document_options=["a2paper"]);

text1 = """At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id.""";

text2 = """quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis olor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessit atibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.""";

text3 = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duisaute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla ariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum""";

doc.content_separator = '\t\t'

with doc.create(Paragraph("")):
	doc.append(LargeText( bold("Respected sir,")));

with doc.create(Paragraph("Paragraph1")):
	doc.append(text1);

with doc.create(Paragraph("Paragraph2")):
	doc.append(text2);

with doc.create(Paragraph("")):
	doc.append(text3);

doc.generate_pdf(clean_tex=False)

When I am executing the above code it works fine, 2nd time & 3rd time it shows erros, finally again 4th time it runs fine. I am not sure about this issue.

Please help me to understand this issue as I want to progress quickly with the usage of PyLaTeX.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Professional lorem ipsum generator for typographers
Lorem Ipsum copy in various charsets and languages for layouts. ... This generator doesn't just add chunks of predefined text with a limited...
Read more >
text-indent - CSS: Cascading Style Sheets - MDN Web Docs
The text-indent CSS property sets the length of empty space (indentation) that is put before lines of text in a block.
Read more >
Adjust Indents and Tabs for Bullet Lists for a Business Report ...
Use the ruler in Word to make slight adjustments to the first-line indent, hanging indent, and tab stop. These formatting items are ...
Read more >
20 awesome Lorem Ipsum alternatives - Justinmind
20 Awesome Lorem Ipsum Alternatives · Tired of reading the words "Lorem Ipsum" time and time again? · Design UI and UX for...
Read more >
Proper indentation for multiline strings? - python
If a text file does not work well for your application and you don't want to postprocess, ... def example(): long_string = '''\...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found