Skip to content

Source code for a chrome extension used to communicate with a translation server, which converts LaTeX formulae to a format understood by most calculators

License

Notifications You must be signed in to change notification settings

OtsoBear/LatexToCalc

Repository files navigation

LatexToCalc Chrome Extension v2.0

LatexToCalc is a powerful Chrome extension that simplifies working with mathematical formulas. It now includes two major features:

  1. LaTeX to Calculator Converter - Translates LaTeX formulas into calculator-compatible syntax (TI-Nspire CX CAS or Speedcrunch)
  2. MathJax to LaTeX Converter (NEW!) - Click on any MathJax equation to copy it as LaTeX

πŸš€ What's New in Version 2.0

  • MathJax to LaTeX Support: Click on any MathJax equation on a webpage to instantly copy it as LaTeX
  • Tabbed Interface: Clean, organized popup with separate tabs for each feature
  • Feature Toggles: Enable or disable each feature independently
  • Improved Performance: Optimized code structure with modular architecture
  • Enhanced Compatibility: Better support for various math websites

πŸ“‹ Features

LaTeX to Calculator Converter

  • Translates LaTeX formulas to TI-Nspire or Speedcrunch syntax
  • Keyboard shortcut: Ctrl + Shift + Z (customizable)
  • Works with selected text, focused equations, or clipboard content
  • Server-based translation for accuracy
  • Customizable constants handling (Coulomb's constant, Euler's number, etc.)

MathJax to LaTeX Converter

  • Click-to-copy functionality for MathJax equations
  • Visual hover highlighting
  • Supports both SVG and CHTML MathJax formats
  • Works on any website with MathJax equations
  • Special optimizations for kampus.sanomapro.fi

🎯 How to Use

LaTeX to Calculator

  1. Select a LaTeX formula on any webpage, or copy it to your clipboard
  2. Press Ctrl + Shift + Z (or your custom shortcut)
  3. The translated formula is automatically copied to your clipboard
  4. Paste it into your calculator

MathJax to LaTeX

  1. Navigate to any webpage with MathJax equations
  2. Hover over an equation to see the purple highlight
  3. Click on the equation
  4. The LaTeX code is automatically copied to your clipboard
  5. You'll see a "Copied!" notification

βš™οΈ Configuration

Calculator Settings

  • TI-Nspire: Optimizes output for TI-Nspire CX CAS calculators (default)
  • Speedcrunch: Formats output for Speedcrunch calculator

Constants Handling

  • Constants: General toggle for mathematical constants
  • k as Coulomb's constant: Treats 'k' as Coulomb's constant in equations
  • e as Euler's number: Treats 'e' as Euler's number (β‰ˆ2.71828)
  • i as imaginary unit: Treats 'i' as the imaginary unit (√-1)
  • g as gravity: Treats 'g' as the gravitational constant

Feature Toggles

  • Enable/disable LaTeX to Calculator converter
  • Enable/disable MathJax to LaTeX converter

🌐 Supported Websites

The extension has been tested and works perfectly with:


πŸ”§ Installation

From Chrome Web Store

  1. Visit the Chrome Web Store page for LatexToCalc
  2. Click Add to Chrome
  3. The extension is ready to use!

From Source Code

  1. Clone or download this repository
  2. Open Chrome and go to chrome://extensions/
  3. Enable "Developer mode" in the top-right corner
  4. Click "Load unpacked" and select the LatexToCalc folder
  5. The extension is now installed

⌨️ Keyboard Shortcuts

  • LaTeX to Calculator: Ctrl + Shift + Z (Windows/Linux) or Cmd + Shift + Z (Mac)
  • To customize: Visit chrome://extensions/shortcuts

πŸ› Troubleshooting

LaTeX to Calculator Issues

  • Shortcut not working: Visit chrome://extensions/shortcuts to set/verify the shortcut
  • Translation fails: Check your internet connection (server-based translation requires internet)
  • No output: Ensure you have text selected or content in clipboard

MathJax to LaTeX Issues

  • Equations not clickable: Refresh the page - the extension needs to detect MathJax elements
  • No hover effect: Check if MathJax to LaTeX is enabled in settings
  • Wrong output: Some complex equations may require manual adjustment

πŸ”’ Privacy

  • The extension only processes mathematical formulas
  • LaTeX to Calculator sends formulas to our secure translation server
  • MathJax to LaTeX works entirely locally in your browser
  • No personal data is collected or stored
  • All settings are saved locally in your browser

πŸ“ Technical Details

Architecture

  • Modular Design: Separate modules for each feature
  • Namespace Isolation: Features don't interfere with each other
  • Performance Optimized: Lazy loading and caching mechanisms
  • Clean Code: Well-documented and maintainable codebase

File Structure

LatexToCalc/
β”œβ”€β”€ manifest.json           # Extension configuration
β”œβ”€β”€ popup.html/js          # Unified popup interface
β”œβ”€β”€ content.js             # Main content script
β”œβ”€β”€ background.js          # Service worker
β”œβ”€β”€ config.js              # Configuration constants
β”œβ”€β”€ timing.js              # Performance tracking
└── mathJaxToLatex/        # MathJax to LaTeX module
    β”œβ”€β”€ content-mjl.js     # MathJax detection and conversion
    β”œβ”€β”€ translate.js       # Core conversion logic
    β”œβ”€β”€ utils.js           # Utility functions
    β”œβ”€β”€ config/            # Configuration files
    └── modules/           # Conversion modules

🀝 Contributing

Contributions are welcome! Please feel free to submit issues or pull requests on our GitHub repository.


πŸ“„ License

This extension is provided as-is for educational and personal use.


πŸ‘¨β€πŸ’» Author

Created by Otso VeisterΓ€


πŸ“š Version History

v2.0.1 (2025-09-23)

  • Fixed: Allow typing in \cases and \matrix fields
  • Added: Domain exclusion logic to disable MathJaxToLatex on specific domains
  • Updated: Warmup expression, dynamic version display in popup, and settings separator
  • Added: CONTRIBUTING.md with contribution guidelines
  • Added: GNU GPL v3 License
  • Updated: Issue templates
  • Files updated: manifest.json (version bump), mathJaxToLatex/content-mjl.js, background.js, popup.html, popup.js, styles.css, mathJaxToLatex/config/settings.js, CONTRIBUTING.md, LICENSE, .github/ISSUE_TEMPLATE/

v2.0.0 (2025-09-04)

  • Integrated MathJaxToLatex into the main extension
  • Added tabbed interface and feature toggles
  • Improved performance with modular architecture
  • Refactored configuration settings and timing management
  • Updated default settings to disable constants option
  • Files updated: README.md, manifest.json, mathJaxToLatex/ (multiple files), popup.html, popup.js, background.js, config.js, content.js, timing.js

v1.5.0

  • Initial public release
  • LaTeX to Calculator conversion
  • Support for TI-Nspire and Speedcrunch
  • Customizable constants handling

πŸ™ Acknowledgments

Special thanks to all users who provided feedback and suggestions for improvements!

About

Source code for a chrome extension used to communicate with a translation server, which converts LaTeX formulae to a format understood by most calculators

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published