With pylatex how do I place a path expression (eg. a matrix) inside a section's title?

101 Views Asked by At

enter image description here

I am trying to make this exam paper with pylatex. I think the best solution is to make sections for each problem, however I could not figure out how to make a math enviroment inside a section's title. Is that possible?

I tried to make a math enviroment inside the section title, but it comes up with an UnicodeDecodeError.

if __name__ == '__main__':
    M = np.matrix([[-3, 2],
                   [1, -2]])
    matrix = Matrix(M, mtype='b')
    # Basic document
    doc = Document()
    
    
    with doc.create(Section('First problem: ' )) as sec:
        sec.append(Math(inline=True, data=['2x+y^2=16', matrix], escape=False))
        sec.title=(Math(data=[matrix]))
        
    with doc.create(Section('some section')):
        doc.append('some text')

    doc.generate_pdf('atest', clean_tex=False)
    tex = doc.dumps()
0

There are 0 best solutions below