LaTeX, LLMs and Boring Technology

(eli.thegreenplace.net)

5 points | by ibobev 9 hours ago ago

1 comments

  • gbacon 8 hours ago

    TikZ is definitely nice. For generating vector versions of your matplotlib plots, use FigureCanvasPgf.

    https://matplotlib.org/stable/api/backend_pgf_api.html#matpl...

    In Jupyter, that looks like

        !sudo apt-get -y install \
          texlive-xetex texlive-fonts-recommended texlive-plain-generic \
          texlive-latex-extra texlive-fonts-recommended dvipng cm-super \
          >/dev/null
    
        import matplotlib
    
        from matplotlib.backends.backend_pgf import FigureCanvasPgf
        matplotlib.backend_bases.register_backend('pdf', FigureCanvasPgf)
    
        import matplotlib.pyplot as plt
        from pdf2image import convert_from_path
    
        plt.rcParams.update({
            'font.family': 'serif',
            'font.serif': [],
            'font.size': 8,
            'text.usetex': True,
            'pgf.rcfonts': False,
        })
    
    Using `convert_from_path` is for showing cached images.

    Generate your figure with

        plt.savefig('foo.pdf', transparent=True)