thethunderturner/filament-latex
Add LaTeX math rendering to your Filament admin panel. thethunderturner/filament-latex provides an easy way to display formulas in form fields, infolists, and tables, bringing clean, readable equations to your Laravel back office.
Installation
composer require thethunderturner/filament-latex
Publish the package assets (if needed):
php artisan vendor:publish --provider="TheThunderTurner\FilamentLatex\FilamentLatexServiceProvider" --tag="filament-latex-assets"
First Use Case Register the editor in a Filament resource or panel:
use TheThunderTurner\FilamentLatex\Widgets\LatexEditor;
public static function getWidgets(): array
{
return [
LatexEditor::make('latex_content')
->label('LaTeX Formula')
->required()
->columnSpanFull(),
];
}
Where to Look First
README.md for basic configuration and examples.src/Widgets/LatexEditor.php for customization options.resources/views/vendor/filament-latex for default UI tweaks.Embedding in Resources Use the widget in Filament resources for inline LaTeX editing:
public static function form(Form $form): Form
{
return $form
->schema([
LatexEditor::make('equation')
->helperText('Enter LaTeX equations here (e.g., \frac{a}{b})')
->livewireOptions(['minHeight' => 400]),
]);
}
Panel-Level Integration Add the editor globally to a Filament panel:
FilamentLatex::make()
->registerEditor('global_editor')
->defaultConfig(['minHeight' => 300]);
Livewire + Filament Sync Sync the editor with a Livewire component:
public function mount()
{
$this->form->fill([
'latex_field' => $this->record->latex_content ?? '',
]);
}
public function save()
{
$this->validate();
$this->form->save();
// Render LaTeX output via a separate component
}
laravel-mathjax or katex).text or longtext MySQL column.->rules(['latex_field' => 'required|string|max:10000'])
Asset Loading
npm run dev or npm run build if customizing assets. Ensure filament-latex JS/CSS is included in your Filament panel:
FilamentLatex::make()->includeAssets();
Livewire Conflicts
LatexEditor::make('latex_field')
->wireModel('latexContent')
->dehydrateStateUsing(fn ($state) => $state)
->hydrateStateUsing(fn ($state) => $state),
LaTeX Rendering
spatie/laravel-mathjax to render LaTeX in Blade views:
{!! mathjax($record->latex_content) !!}
config/filament-latex.php:
'debug' => env('APP_DEBUG', false),
/vendor/filament-latex/js/editor.js or similar.Uncaught ReferenceError or MathJax initialization issues.Custom Toolbar Override the toolbar buttons via config:
FilamentLatex::make()->toolbarButtons([
'bold', 'italic', 'frac', 'sqrt', 'custom_button' => [
'label' => 'My Button',
'action' => 'insertText(\\text{custom})',
],
]);
Syntax Highlighting
Extend the editor’s CodeMirror instance:
// In a custom JS file
document.addEventListener('filament-latex-ready', (e) => {
e.detail.editor.addMode('latex', { ... });
});
Export/Import Add methods to serialize/deserialize LaTeX:
public function getLatexOutputAttribute()
{
return $this->latex_content ? mathjax($this->latex_content, 'svg') : null;
}
How can I help you explore Laravel packages today?