-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working #18
Comments
The formula is probably part of a doc-string. You can change that through the following lines in your init file. TeX-fragments are recognized anywhere in the code with that change. (defvar texfrag-comments-only) ;; Defined in texfrag.el
(defun texfrag-python ()
"texfrag setup for Python."
(setq texfrag-comments-only nil))
(eval-after-load "texfrag"
(lambda ()
(add-to-list 'texfrag-setup-alist '(texfrag-python python-mode)))) Note that texfrag works with LaTeX. So your comment should look like following:
|
You can also use the following Elisp code for Python. (declare-function 'python-info-docstring-p "python")
(defun texfrag-python-next-frag (&optional bound)
"Search for TeX fragments in comments and `python-info-docstring-p'.
Set `texfrag-comments-only' to nil to use this function as
`texfrag-next-frag-function'."
(let (found)
(while (and
(setq found (texfrag-next-frag-default bound))
(null
(or (nth 4 (syntax-ppss)) ;; in comment
(python-info-docstring-p)))))
found))
(defun texfrag-python-previous-frag (&optional bound)
"Search for TeX fragments in comments and `python-info-docstring-p'.
Set `texfrag-comments-only' to nil to use this function as
`texfrag-previous-frag-function'."
(let (found)
(while (and
(setq found (texfrag-previous-frag-default bound))
(null
(or (nth 4 (syntax-ppss)) ;; in comment
(python-info-docstring-p)))))
found))
(defun texfrag-python ()
"Texfrag setup for Python."
(setq texfrag-comments-only nil
texfrag-next-frag-function #'texfrag-python-next-frag
texfrag-previous-frag-function #'texfrag-python-previous-frag))
(eval-after-load "texfrag"
(lambda ()
(add-to-list 'texfrag-setup-alist '(texfrag-python python-mode)))) If you test this code for a while and give me some positive feedback I will add it to My first rudimentary test: # Some fragment in a comment interpreted by texfrag \f$\sqrt{x^2 + y^2}\f$.
def fun(A,x,y,w):
'''
Some documentation string:
n_iterations: float
The number of training iterations the algorithm will tune the weights for.
\f[\min_A \sum_{X,y,w} w \left\| \frac{A_{12} x}{A_3 x_1} - y\right\|^2\f]
'''
print "Some fragment \f[\sqrt{x^2 + y^2}\f] in a string not interpreted as TeX."
return {sum(A[i][j]*x[j] for j in length(A[0])) for i in length(A)}; Test with
|
Hi thanks for the suggestions. I"m still not able to properly render your test example. Initially I was using emacs on the terminal which made me realize that it's not gonna work there so I switched to gui and now it properly produces the .tex file filled with everything but when I run preview at point still doesn't render the equation. I see that inside the texfrag folder there's .pdf file generated containing the equation from your initial oneliner comment But I would like this Is there any possible way to make this work for emacs terminal? Thanks! |
About the missing display formula:
|
Yes it works fine
Yes I have that as well
Hope that helps! |
|
Hi just installed and tried your package on python code comments and nothing happens when executing preview at point. It simply generates a .tex file with variables pointing to the .py file.
Am I doing somehting wrong here?
The text was updated successfully, but these errors were encountered: