hep: go-hep.org/x/hep/hplot/htex Index | Examples | Files

package htex

import "go-hep.org/x/hep/hplot/htex"

Index

Examples

Package Files

handler.go latex.go

Variables

var (
    // DefaultHandler generates PDFs via the pdflatex executable.
    // A LaTeX installation is required, as well as the pdflatex command.
    DefaultHandler = NewHandler("pdflatex")
)

type GoHandler Uses

type GoHandler struct {
    // contains filtered or unexported fields
}

GoHandler is a Latex handler that compiles Latex document in background goroutines.

Code:

hdlr := htex.NewGoHandler(-1, "pdflatex")

for i := 0; i < 10; i++ {
    name := fmt.Sprintf("plot-%0d", i)
    p := hplot.New()
    p.Title.Text = name
    p.X.Label.Text = "x"
    p.Y.Label.Text = "y"

    err := hplot.Save(
        hplot.Figure(p, hplot.WithLatexHandler(hdlr)),
        -1, -1, name+".tex",
    )
    if err != nil {
        log.Fatalf("could not save plot: %+v", err)
    }
}

err := hdlr.Wait()
if err != nil {
    log.Fatalf("error compiling latex: %+v", err)
}

func NewGoHandler Uses

func NewGoHandler(n int, cmd string) *GoHandler

NewGoHandler creates a new Latex handler that compiles Latex document in the background with the cmd executable.

The handler allows for up to n concurrent compilations. If n<=0, the concurrency will be set to the number of cores+1.

func (*GoHandler) CompileLatex Uses

func (gh *GoHandler) CompileLatex(fname string) error

CompileLatex compiles the provided .tex document.

func (*GoHandler) Wait Uses

func (gh *GoHandler) Wait() error

type Handler Uses

type Handler interface {
    // CompileLatex compiles the provided .tex document.
    CompileLatex(fname string) error
}

Handler is the interface that handles the generation of PDFs from TeX, usually via pdflatex.

func NewHandler Uses

func NewHandler(cmd string) Handler

NewHandler returns a Handler compiling .tex documents with the provided cmd executable.

type NoopHandler Uses

type NoopHandler struct{}

NoopLatexHandler is a no-op LaTeX compiler.

func (NoopHandler) CompileLatex Uses

func (NoopHandler) CompileLatex(fname string) error

Package htex imports 9 packages (graph) and is imported by 3 packages. Updated 2020-10-19. Refresh now. Tools for package owners.