I wrote a nbextension that does exactly this.  
See https://github.com/ipython-contrib/jupyter_contrib_nbextensions/pull/1257.

On Monday, July 25, 2016 at 12:42:00 AM UTC+3, takowl wrote:
>
> Sorry, no ideas spring to mind; I don't know much about the details of how 
> Mathjax works. Someone else might be able to help you more.
>
> On 24 July 2016 at 16:40, Keir Lockridge <[email protected] <javascript:>
> > wrote:
>
>> Actually, I find that when I reload the notebook I have to re-run all the 
>> markdown cells (after executing the code cell with the 
>> IPython.display.Latex object), otherwise any LaTeX code in the document 
>> using the macros doesn't display properly.
>>
>> In the first cell of the notebook I have:
>>
>> import IPython.display
>>
>> IPython.display.display_latex(IPython.display.Latex(filename="LaTeXmacros"))
>>
>> If I run this cell and then make markdown cells using my macros, it 
>> works. When I reload the notebook, none of my macros are rendered properly 
>> (even if I re-run the top cell) until I re-run each markdown cell.
>>
>> Is there a way to avoid this?
>>
>> --Keir
>>
>> On Saturday, July 23, 2016 at 6:43:05 PM UTC-4, takowl wrote:
>>>
>>> On 23 July 2016 at 22:24, Keir Lockridge <[email protected]> wrote:
>>>
>>>> It seems that latex macros may be included in any markdown cell 
>>>> (between dollar signs), and these macros are then available throughout the 
>>>> notebook. Is there a way to load a file containing LaTeX macros in a 
>>>> markdown cell (or in some other location, if it gets the job done)? I am 
>>>> trying to avoid having to cut-and-paste a long list of LaTeX macros into 
>>>> every Jupyter Notebook I create.
>>>>
>>>
>>> You can construct an IPython.display.Latex object with a string - which 
>>> you could read from a file. When that object is displayed, its content is 
>>> added to the page as Latex.
>>>
>>> Within the notebook interface, Latex is rendered by the Mathjax library, 
>>> so only a subset of Latex works, but it sounds like what you want to do is 
>>> already working.
>>>
>>> Thomas
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Project Jupyter" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jupyter/f9c58601-14d7-44af-8c18-744ee93b54a3%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jupyter/f9c58601-14d7-44af-8c18-744ee93b54a3%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/86414ff3-3073-4989-91c0-cf35baab830c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to