I have started using pylatex four days ago to automate report generation (I have no earlier experience in latex as well). The text that I want to enter in the latex report has been generated by an online server and stored in my file as a text file. In the text file, there exist places with more than one simultaneous space for proper formatting and aligning (Protein Sequence Alignment). Hence, while simply trying to use .append, pylatex seems to ignore all the extra spaces on its own. I searched the internet with various relevant terms, but could not find any answer for pylatex. I did find some latex answers, exploring which I tried to incorporate pylatex's NoEscape and explicitly replacing " " (double spaces) with " \space ", it seems to work for some lines as expected, but not for others (maybe some of the places have \ (or some other special characters for latex) which are expected to be meaningful but could not understand what it actually means since it does not even exist (for example \clo). Can someone please suggest a method where I can simply allow the simultaneous existence of the spaces, which is also visible in the final document without the need to think about the existence of a possible special character that needs to be escaped. The following code snippets that I used might be of use to answer/understand my query.
i = 0
with doc.create(Subsection('Details')):
with open(whatcheck_detail, 'r') as fh:
lines = fh.read().split("#")[1:]
for line in lines:
i += 1
line = line.replace(" ", " \space ").replace("#", "\#") + "\n"
if "Note:" in line:
print(i)
# doc.append(TextColor(line))
doc.append(NoEscape(line))
elif "Warning:" in line:
print(i)
# line = "\color{blue} " + line
doc.append(NoEscape(line))
# doc.append(TextColor("blue", line))
elif "Error:" in line:
print(i)
# line = "\color{red} " + line
doc.append(NoEscape(line))
# doc.append(TextColor("red", line))
And the following is the screenshot of the last part of the error report. Error Description upon running the above script.
Following are the images of what is happening by using the simple pylatex code doc.append(TextColor("color", line))
, and what is actually in the text file (which is how I want it to be on PDF generated by latex/pylatex).
What is happening to the text in the output file.
What is in the text file, or how do I want it.
Thank you!