我正在尝试生成以下 pdf:
我使用以下代码:
with doc.create(Center()) as centered:
with centered.create(Section("Reportes de clientes", numbering = False)) as customers:
with customers.create(Tabu("X[c] X[c]")) as customers_table:
stock = Subsection(df["df_name"], numbering = False)
stock.append(NoEscape(final_df.loc[tenant, (df["df_name"])].astype(np.float64).to_latex()))
movement = Subsection(df1["df_name"], numbering = False)
movement.append(NoEscape(final_df.loc[tenant, (df1["df_name"])].astype(np.float64).to_latex()))
customers_table.add_row([stock, movement])
pdf 已创建,但它在日志中返回错误,如下所示:
! You can't use `\hrule' here except with leaders.
\tabu@verticalspacing ...nalstrut \@gobble \hrule
height\@tempdima depth\@te...
l.44 \end{tabu}
To put a horizontal rule in an hbox or an alignment,
you should use \leaders or \hrulefill (see The TeXbook).
! Missing number, treated as zero.
<to be read again>
d
l.44 \end{tabu}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Illegal unit of measure (pt inserted).
<to be read again>
d
l.44 \end{tabu}
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)
而且由于它处于循环内,因此无法继续执行代码。我对 pylatex 和 latex 都很陌生,所以在这里我有点迷茫。
答案1
经过进一步的测试,我终于实现了目标。最终创建了一个带有以下内容Centered
的部分:Tabular
with doc.create(Center()) as centered:
with centered.create(Section("Visualización en minutos", numbering = False)) as visualization:
with visualization.create(Tabular("c c")) as visualization_table:
visualization_table.add_hline()
visualization_table.add_empty_row()
visualization_table.add_row((df2["df_name"], df3["df_name"]))
visualization_table.add_row((NoEscape(final_df.loc[tenant, (df2["df_name"])].astype(np.float64).to_latex()), NoEscape(final_df.loc[tenant, (df3["df_name"])].astype(np.float64).nlargest(10).to_latex())))