Skip to content
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

Conversion to slide not taking extensions into account #36

Open
hugues-talbot opened this issue Feb 20, 2018 · 7 comments
Open

Conversion to slide not taking extensions into account #36

hugues-talbot opened this issue Feb 20, 2018 · 7 comments

Comments

@hugues-talbot
Copy link

Hello,

I cannot make use of both reveal.js slides and latex notebook extensions. In the slides, I simply get the unconverted code (see screenshot).

In other words, a command like

jupyter nbconvert --to slides_with_lenvs

is mssing.

screenshot 2018-02-20 16 52 22

@jfbercher
Copy link
Owner

This is a good idea for improvement and should be easy.
For now, you can try to

  • locate the templates associated with the latex_envs package; in my system they are located in /usr/local/lib/python3.5/site-packages/latex_envs/templates; but this depends on the system you use and the way you installed the package (as a system or user package)
  • edit the template latex_envs.tpl and replace {%- extends 'full.tpl' -%}(first line) by {%- extends 'slides_reveal.tpl' -%}

AhAh. No. Not that easy. :-(
There is a dedicated exporter for slides, which adds data to the notebook itself before conversion; so one has to keep all that in a special preprocessor. I write this in my todo...


If you are really in a hurry, you can (probably) convert to slides, and then add latex_envs support by hands.
Add this at the beginning

<!-- javascript from CDN for conversion -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.js"></script>

<script type="text/x-mathjax-config">
// make sure that equations numbers are enabled
MathJax.Hub.Config({ TeX: { equationNumbers: {
    autoNumber: "AMS", // All AMS equations are numbered
    useLabelIds: true, // labels as ids
    // format the equation number - uses an offset eqNumInitial (default 0)
    formatNumber: function (n) {return String(Number(n)+Number(1)-1)} 
    } } 
});
</script>

and this at the end of the head (before </head>)

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

<!-- stylesheet from CDN -->
<link rel="stylesheet" type="text/css" href="https://rawgit.com/jfbercher/jupyter_latex_envs/master/src/latex_envs/static/latex_envs.css">

<!-- Custom stylesheet, it must be in the same directory as the html file -->
<link rel="stylesheet" href="custom.css"> 

<!-- Load mathjax 
<script src="https://rawgit.com/ipython-contrib/jupyter_contrib_nbextensions/master/src/jupyter_contrib_nbextensions/nbextensions/latex_envs/thmsInNb4.js"></script>
-->
<script type="text/javascript"  src="https://rawgit.com/jfbercher/jupyter_latex_envs/master/src/latex_envs/static/thmsInNb4.js"> </script>



<script>
$( document ).ready(function(){

        //Value of configuration variables, some taken from the notebook's metada. 
        eqNum = 0; // begins equation numbering at eqNum+1
        eqLabelWithNumbers = "True"=="True" ? true : false; //if true, label equations with equation numbers; 
                                       //otherwise using the tag specified by \label
        conversion_to_html = false;
        current_cit=1;
        cite_by='key';  //only number and key are supported
        //var document={}
        document.bibliography={};

        // Read environment map config
        initmap();
        // Read user envs config, if specified        
                environmentMap = $.extend(true,{}, environmentInitialMap)                

        // fire the main function with these parameters
        var html_to_analyse = $('body').html()
        var html_converted = thmsInNbConv(marked,html_to_analyse);
        html_converted = html_converted.replace(/%[\S\t ]*<\/p>/gm,"</p>")
        $('body').html(html_converted)
        // Show/hide anchors
        var labels_anchors = "False"=="True" ? true : false;
        $('.latex_label_anchor').toggle(labels_anchors)
        // Number all environments
        report_style_numbering = "False"=="True" ? true : false;
        reset_counters();
        renumberAllEnvs();
    });
</script

@jfbercher
Copy link
Owner

Export to slides using

jupyter nbconvert --to slides_with_lenvs FILE.ipynb

is available in version 1.4.3 at Pypi of in this repo. Enjoy.

@hugues-talbot
Copy link
Author

hugues-talbot commented Feb 26, 2018 via email

@jfbercher
Copy link
Owner

There is no screenshot.

Anyway this is probably unrelated to latex_envs. It means that your mathjax processor fails somewhere; because of your browser, your internet connexion or of cache issues. Try to clear the cache (press shift while reloading; or use your browser preferences).

@hugues-talbot
Copy link
Author

hugues-talbot commented Feb 27, 2018 via email

@hugues-talbot
Copy link
Author

hugues-talbot commented Feb 27, 2018 via email

@jfbercher
Copy link
Owner

😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants