मैं मनमाने ढंग से मोड में TeX सूत्र इनलाइन का पूर्वावलोकन कैसे कर सकता हूं?


14

मुझे AUCTeX या org-mode के अलावा अन्य मोड के अंदर TeX पूर्वावलोकन कैसे मिल सकते हैं? मैं jabber, erc और markdown में TeX समीकरण देखना पसंद करूंगा। अगर मैं कभी ईमेल के लिए एमएसीएस पर जाता हूं, तो मैं शायद वहां भी पूर्वावलोकन देखना चाहता हूं।


1
मैंने यह कोशिश नहीं की है, लेकिन आप mmm-modeएक बफर में कई प्रमुख मोडों को देखने की अनुमति दे सकते हैं
वामसी

जवाबों:


10

मैंने AUCTeX पूर्वावलोकन-लेटेक्स का फिर से उपयोग करने की कोशिश की है, लेकिन असफल रहा और हार मान ली।

ऑर्ग-मोड भी एक ही सुविधा प्रदान करते हैंवीचैट चालू करता है, इसे स्वचालित रूप से लेटेक्स पूर्वावलोकन दिखाने के लिए फिर से उपयोग करने में कामयाब रहा।

मैंने वीचैट से पूर्वावलोकन भाग को एक अलग फ़ाइल में निकाला है जिसे आप इस रेपो पर प्राप्त कर सकते हैं । यह pxMELPA पर पैकेज के रूप में भी उपलब्ध है (मैंने इसे अभी प्रस्तुत किया है)।

4 प्रविष्टि बिंदु हैं जिन्हें अंतःक्रियात्मक रूप से कहा जा सकता है:

  • px-preview: वर्तमान बफर में सभी लेटेक्स टुकड़े प्रस्तुत करना।
  • px-preview-region: क्षेत्र में टुकड़े प्रस्तुत करना।
  • px-remove: वर्तमान बफर से सभी पूर्वावलोकन निकालें (पाठ को पुनर्स्थापित करें)।
  • px-toggle: वर्तमान बफ़र में पूर्वावलोकन का प्रदर्शन टॉगल करें।

जब तक ऑर्ग-मोड प्रीव्यूअर काम करता है, तब तक यह होना चाहिए।

चूंकि कोड अभी भी बहुत छोटा है इसलिए मैं इसे नीचे शामिल करूंगा, लेकिन कृपया पैकेज स्थापित करें या रेपो का उपयोग करें।

;;; px.el --- preview inline latex -*- lexical-binding: t -*-

;; Most of this code comes from weechat-latex.el which in turn uses
;; org-mode previewer.

;; Copyright (C) 2014 Aurélien Aptel <aurelien.aptel@gmail.com>
;; Copyright (C) 2013 Rüdiger Sonderfeld <ruediger@c-plusplus.de>

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

(require 'org)

(defvar px-temp-file-prefix "px-"
  "Prefix for temporary files.")

(defvar px-temp-directory-prefix "px-"
  "Prefix for temporary directory.")

(defvar px-image-program org-latex-create-formula-image-program
  "Program to convert LaTeX fragments.
See `org-latex-create-formula-image-program'")

(defvar px-temp-dir nil
  "The temporary directory used for preview images.")

(defun px--create-preview (at)
  "Wrapper for `org-format-latex'.
The parameter AT should be nil or in (TYPE . POINT) format.  With TYPE being a
string showing the matched LaTeX statement (e.g., ``$'') and POINT being the
POINT to replace.  If AT is nil replace statements everywhere."
  (org-format-latex px-temp-file-prefix
                    px-temp-dir
                    'overlays
                    "Creating images...%s"
                    at 'forbuffer
                    px-image-program))

(defun px--set-temp-dir ()
  "Set `px-temp-dir' unless it is already set."
  (unless px-temp-dir
    (setq px-temp-dir
          (make-temp-file px-temp-directory-prefix
                          'directory))))

(defun px-preview ()
  "Preview LaTeX fragments."
  (interactive)
  (save-excursion
    (let ((inhibit-read-only t))
      (px--set-temp-dir)
      (org-remove-latex-fragment-image-overlays)
      (px--create-preview nil))))

(defun px-preview-region (beg end)
  "Preview LaTeX fragments in region."
  (interactive "r")
  (let* ((math-regex (assoc "$" org-latex-regexps))
         (regex (nth 1 math-regex))
         (n (nth 2 math-regex))
         matches)
    (save-excursion
      (goto-char beg)
      (while (re-search-forward regex end t)
        (setq matches (cons (cons "$" (match-beginning n)) matches)))
      (let ((inhibit-read-only t))
        (px--set-temp-dir)
        (dolist (i matches)
          (px--create-preview i))))))


(defun px-remove ()
  "Remove LaTeX preview images."
  (interactive)
  (let ((inhibit-read-only t))
    (org-remove-latex-fragment-image-overlays)))

(defun px-is-active? ()
  "Are LaTeX Previews currently displayed?"
  org-latex-fragment-image-overlays)

(defun px-toggle ()
  "Toggle display of LaTeX preview."
  (interactive)
  (if (px-is-active?)
      (px-remove)
    (px-preview)))


(provide 'px)

0

वहाँ भी है texfrag.elजो बॉक्स के बाहर काम करता है में doxygen टिप्पणियों के लिए prog-mode

आप के माध्यम texfrag.elसे स्थापित कर सकते हैं ।melpa-stableM-x package-install RET texfrag RET

M-x texfrag-mode RETपूर्वावलोकन सक्रिय करने के लिए चलाएँ । आपको AUCTeX पूर्वावलोकन पैकेज के सभी आइटमों के साथ पूर्वावलोकन मेनू मिलता है।

ध्यान दें, यह texfraghtml स्रोत, eww और org-mode संपादन के लिए भी काम करता है।

हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.