定制 jagermesh/latex-tools 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jagermesh/latex-tools

最新稳定版本:1.0.23

Composer 安装命令:

composer require jagermesh/latex-tools

包简介

Library to render LaTeX formula into image

README 文档

README

Library to render LaTeX formula into image

Requirements

Linux

Mac OS

$ sudo tlmgr update --self
$ sudo tlmgr install dvipng

Installation

Easiest way is to use composer

composer require jagermesh/latex-tools

Usage

<?php
  require_once(__DIR__ . '/vendor/autoload.php');

  // Or library directly
  // require_once('LatexTools.php');

  $latexTools = new \LatexTools\LatexTools();
  $latexTools->renderIntoResponse('(\frac{\beta }{\mu})^\beta {\Gamma(\beta )} \,  e^{-\frac{V\,\beta }{\mu }} \label{gamma}');

Will render this nice formula :)

Functions reference

Render formula and return image in response

$latexTools->renderIntoResponse($formula, $params = []);

Render image into file

$fileName = $latexTools->renderIntoFile($formula, $params = []);

In above calls $params could be any of these values:

  • density - formula density
  • fallbackToImage - if need to render regular image for incorrect formula (true by default)
  • fallbackImageFontName - font name for regular image (fonts/PlayfairDisplay-Regular.ttf by default)
  • fallbackImageFontSize - font size for regular image (16 by default)

Also these paramatares could be set globally. Please see below.

Set formula density (160 by default)

$latexTools->setDensity($value);

By default regular image will be rendered if formula incorrect (true by default)

$latexTools->setFallbackToImage(true|false);

Example

<?php
  require_once(__DIR__ . '/vendor/autoload.php');

  $latexTools = new \LatexTools\LatexTools();
  $latexTools->renderIntoResponse('x^2');

Font name for regular image (fonts/PlayfairDisplay-Regular.ttf by default)

$latexTools->setFallbackImageFontName($value);

Font size for regular image (16 by default)

$latexTools->setFallbackImageFontName($value);

Check if formula correct

$result = $latexTools->isValidLaTeX($formula);

Set directory for cache files (/tmp by default)

$latexTools->setCachePath($value);

Set directory for temp files (/tmp by default)

$latexTools->setTempPath($value);

统计信息

  • 总下载量: 103
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-26