gpt2-pos-encoding-experiment-100B
/
.local
/share
/jupyter
/nbextensions
/highlighter
/export_highlights.tex
% Default to the notebook output style | |
% Inherit from the specified cell style. | |
\documentclass{article} | |
\usepackage{graphicx} % Used to insert images | |
\usepackage{adjustbox} % Used to constrain images to a maximum size | |
\usepackage{color} % Allow colors to be defined | |
\usepackage{enumerate} % Needed for markdown enumerations to work | |
\usepackage{geometry} % Used to adjust the document margins | |
\usepackage{amsmath} % Equations | |
\usepackage{amssymb} % Equations | |
\usepackage{eurosym} % defines \euro | |
\usepackage[mathletters]{ucs} % Extended unicode (utf-8) support | |
\usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document | |
\usepackage{fancyvrb} % verbatim replacement that allows latex | |
\usepackage{grffile} % extends the file name processing of package graphics | |
% to support a larger range | |
% The hyperref package gives us a pdf with properly built | |
% internal navigation ('pdf bookmarks' for the table of contents, | |
% internal cross-reference links, web links for URLs, etc.) | |
\usepackage{hyperref} | |
\usepackage{longtable} % longtable support required by pandoc >1.10 | |
\usepackage{booktabs} % table support for pandoc > 1.12.2 | |
\usepackage{color} | |
\usepackage{soul} | |
\usepackage[framemethod=tikz]{mdframed} | |
\definecolor{orange}{cmyk}{0,0.4,0.8,0.2} | |
\definecolor{darkorange}{rgb}{.71,0.21,0.01} | |
\definecolor{darkgreen}{rgb}{.12,.54,.11} | |
\definecolor{myteal}{rgb}{.26, .44, .56} | |
\definecolor{gray}{gray}{0.45} | |
\definecolor{lightgray}{gray}{.95} | |
\definecolor{mediumgray}{gray}{.8} | |
\definecolor{inputbackground}{rgb}{.95, .95, .85} | |
\definecolor{outputbackground}{rgb}{.95, .95, .95} | |
\definecolor{traceback}{rgb}{1, .95, .95} | |
% ansi colors | |
\definecolor{red}{rgb}{.6,0,0} | |
\definecolor{green}{rgb}{0,.65,0} | |
\definecolor{brown}{rgb}{0.6,0.6,0} | |
\definecolor{blue}{rgb}{0,.145,.698} | |
\definecolor{purple}{rgb}{.698,.145,.698} | |
\definecolor{cyan}{rgb}{0,.698,.698} | |
\definecolor{lightgray}{gray}{0.5} | |
% bright ansi colors | |
\definecolor{darkgray}{gray}{0.25} | |
\definecolor{lightred}{rgb}{1.0,0.39,0.28} | |
\definecolor{lightgreen}{rgb}{0.48,0.99,0.0} | |
\definecolor{lightblue}{rgb}{0.53,0.81,0.92} | |
\definecolor{lightpurple}{rgb}{0.87,0.63,0.87} | |
\definecolor{lightcyan}{rgb}{0.5,1.0,0.83} | |
% commands and environments needed by pandoc snippets | |
% extracted from the output of `pandoc -s` | |
\providecommand{\tightlist}{% | |
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} | |
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} | |
% Add ',fontsize=\small' for more characters per line | |
\newenvironment{Shaded}{}{} | |
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} | |
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}} | |
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}} | |
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}} | |
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | |
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}} | |
\newcommand{\RegionMarkerTok}[1]{{#1}} | |
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | |
\newcommand{\NormalTok}[1]{{#1}} | |
% Define a nice break command that doesn't care if a line doesn't already | |
% exist. | |
\def\br{\hspace*{\fill} \\* } | |
% Math Jax compatability definitions | |
\def\gt{>} | |
\def\lt{<} | |
% Document parameters | |
\title{export\_highlights} | |
\author{} | |
% Pygments definitions | |
\makeatletter | |
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax% | |
\let\PY@ul=\relax \let\PY@tc=\relax% | |
\let\PY@bc=\relax \let\PY@ff=\relax} | |
\def\PY@tok#1{\csname PY@tok@#1\endcsname} | |
\def\PY@toks#1+{\ifx\relax#1\empty\else% | |
\PY@tok{#1}\expandafter\PY@toks\fi} | |
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{% | |
\PY@it{\PY@bf{\PY@ff{#1}}}}}}} | |
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}} | |
\expandafter\def\csname PY@tok@gp\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}} | |
\expandafter\def\csname PY@tok@no\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@il\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | |
\expandafter\def\csname PY@tok@sx\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@kt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}} | |
\expandafter\def\csname PY@tok@mo\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | |
\expandafter\def\csname PY@tok@sh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | |
\expandafter\def\csname PY@tok@bp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@gd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@sb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | |
\expandafter\def\csname PY@tok@err\endcsname{\def\PY@bc##1{\setlength{\fboxsep}{0pt}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}} | |
\expandafter\def\csname PY@tok@nd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}} | |
\expandafter\def\csname PY@tok@gr\endcsname{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@kd\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@s\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | |
\expandafter\def\csname PY@tok@cs\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | |
\expandafter\def\csname PY@tok@sd\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | |
\expandafter\def\csname PY@tok@ss\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | |
\expandafter\def\csname PY@tok@nn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} | |
\expandafter\def\csname PY@tok@w\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}} | |
\expandafter\def\csname PY@tok@kn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@sc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | |
\expandafter\def\csname PY@tok@s1\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | |
\expandafter\def\csname PY@tok@ge\endcsname{\let\PY@it=\textit} | |
\expandafter\def\csname PY@tok@cp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@gh\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}} | |
\expandafter\def\csname PY@tok@gi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@vc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | |
\expandafter\def\csname PY@tok@si\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}} | |
\expandafter\def\csname PY@tok@ow\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}} | |
\expandafter\def\csname PY@tok@vg\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | |
\expandafter\def\csname PY@tok@sr\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}} | |
\expandafter\def\csname PY@tok@cm\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | |
\expandafter\def\csname PY@tok@c\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | |
\expandafter\def\csname PY@tok@mi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | |
\expandafter\def\csname PY@tok@kc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@ne\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}} | |
\expandafter\def\csname PY@tok@nf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} | |
\expandafter\def\csname PY@tok@go\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}} | |
\expandafter\def\csname PY@tok@m\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | |
\expandafter\def\csname PY@tok@mh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | |
\expandafter\def\csname PY@tok@nc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} | |
\expandafter\def\csname PY@tok@mb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | |
\expandafter\def\csname PY@tok@se\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}} | |
\expandafter\def\csname PY@tok@gt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}} | |
\expandafter\def\csname PY@tok@nv\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | |
\expandafter\def\csname PY@tok@c1\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | |
\expandafter\def\csname PY@tok@kp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@s2\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | |
\expandafter\def\csname PY@tok@nb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@ni\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}} | |
\expandafter\def\csname PY@tok@k\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@na\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}} | |
\expandafter\def\csname PY@tok@o\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | |
\expandafter\def\csname PY@tok@mf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | |
\expandafter\def\csname PY@tok@nl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@nt\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\expandafter\def\csname PY@tok@gs\endcsname{\let\PY@bf=\textbf} | |
\expandafter\def\csname PY@tok@vi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | |
\expandafter\def\csname PY@tok@gu\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}} | |
\expandafter\def\csname PY@tok@kr\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | |
\def\PYZbs{\char`\\} | |
\def\PYZus{\char`\_} | |
\def\PYZob{\char`\{} | |
\def\PYZcb{\char`\}} | |
\def\PYZca{\char`\^} | |
\def\PYZam{\char`\&} | |
\def\PYZlt{\char`\<} | |
\def\PYZgt{\char`\>} | |
\def\PYZsh{\char`\#} | |
\def\PYZpc{\char`\%} | |
\def\PYZdl{\char`\$} | |
\def\PYZhy{\char`\-} | |
\def\PYZsq{\char`\'} | |
\def\PYZdq{\char`\"} | |
\def\PYZti{\char`\~} | |
% for compatibility with earlier versions | |
\def\PYZat{@} | |
\def\PYZlb{[} | |
\def\PYZrb{]} | |
\makeatother | |
% Prevent overflowing lines due to hard-to-break entities | |
\sloppy | |
% Setup hyperref package | |
\hypersetup{ | |
breaklinks=true, % so long urls are correctly broken across lines | |
colorlinks=true, | |
urlcolor=blue, | |
linkcolor=darkorange, | |
citecolor=darkgreen, | |
} | |
% Slightly bigger margins than the latex defaults | |
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in} | |
\newcommand{\highlighta}[1]{{\sethlcolor{yellow} \textcolor{red}{\hl{#1}}}} | |
\newcommand{\highlightb}[1]{{\sethlcolor{red} \textcolor{yellow}{\hl{#1}}}} | |
\newcommand{\highlightc}[1]{{\sethlcolor{green} \textcolor{yellow}{\hl{#1}}}} | |
\newenvironment{highlightA}{\begin{mdframed}[hidealllines=true,backgroundcolor=yellow!20]}{\end{mdframed}} | |
\newenvironment{highlightB}{\begin{mdframed}[hidealllines=true,backgroundcolor=red!20]}{\end{mdframed}} | |
\newenvironment{highlightC}{\begin{mdframed}[hidealllines=true,backgroundcolor=green!20]}{\end{mdframed}} | |
%\usepackage{foo} | |
\begin{document} | |
\maketitle | |
\section{Exporting the notebook}\label{exporting-the-notebook} | |
As suggested by @juhasch, it is interesting to keep the highlights when | |
exporting the notebook to another format. We give and explain below some | |
possibilities: | |
\subsection{Short version}\label{short-version} | |
\begin{itemize} | |
\item | |
Html export: | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{nbconvert FILE --config JUPYTER_DATA_DIR/extensions/highlight_html_cfg.py } | |
\end{Highlighting} | |
\end{Shaded} | |
\item | |
LaTeX export: | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{nbconvert FILE --config JUPYTER_DATA_DIR/extensions/highlight_latex_cfg.py } | |
\end{Highlighting} | |
\end{Shaded} | |
where JUPYTER\_DATA\_DIR can be found from the output of | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{--paths} | |
\end{Highlighting} | |
\end{Shaded} | |
eg \texttt{\textasciitilde{}/.local/share/jupyter} in my case. Seems | |
to be | |
\texttt{c:\textbackslash{}users\textbackslash{}NAME\textbackslash{}AppData\textbackslash{}Roaming\textbackslash{}jupyter} | |
under Windows. | |
\end{itemize} | |
Examples can be found here: \href{tst_highlights.ipynb}{initial | |
notebook}, \href{tst_highlights.html}{html version}, | |
\href{tst_highlights.pdf}{pdf version} (after an additional LaTeX | |
\(\rightarrow\) pdf compilation). | |
\subsection{Html export}\label{html-export} | |
This is quite easy. Actually, highlight formatting embedded in markdown | |
cells is preserved while converting with the standard | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{nbconvert file.ipynb} | |
\end{Highlighting} | |
\end{Shaded} | |
However, the css file is missing and must be added. Here we have several | |
possibilities | |
\begin{itemize} | |
\item | |
Embed the css \emph{within} the notebook. For that, consider the last | |
cell of the present notebook. This code reads the css file | |
\texttt{highlighter.css} in the extension directory and displays the | |
corresponding style. So doing the | |
\texttt{\textless{}style\textgreater{}\ ...\textless{}/style\textgreater{}} | |
section will be present in the cell output and interpreted by the web | |
browser. Drawbacks of this solution is that user still have to execute | |
this cell and that the this is not language agnostic. | |
\item | |
Use a \textbf{template file} to link or include the css file during | |
conversion. Such a file is provided as | |
\texttt{templates/highlighter.tpl}. It was choosen here to | |
\emph{include} the css content in the produced html file rather than | |
linking it. This avoids the necessity to keep the css file with the | |
html files. | |
\item | |
This works directly if the css resides in the same directory as the | |
file the user is attempting to convert --thus requires the user to | |
copy \texttt{highlighter.css} in the current directory. Then the | |
conversion is simply | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{nbconvert file.ipynb --template highlighter} | |
\end{Highlighting} | |
\end{Shaded} | |
\item | |
It still remains two problems with this approach. First, it can be | |
annoying to have to systematically copy the css file in the current | |
directory. Second, the data within the html tags is not converted (and | |
thus markdown remains unmodified). A solution is to use a pair of | |
preprocessor/postprocessor that modify the html tags and enable the | |
subsequent markdown to html converter to operate on the included data. | |
Also, a config file is provided which redefines the template path to | |
enable direct inclusion of the css file in the extension directory. | |
Unfortunately, \highlighta{it seems that the \emph{full path} to | |
the config file has to be provided}. This file resides in the | |
extensions subdirectory of the jupyter\_data\_dir. The path can be | |
found by looking at the output of | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{--paths} | |
\end{Highlighting} | |
\end{Shaded} | |
Then the command to issue for converting the notebook to html is | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{nbconvert FILE --config JUPYTER_DATA_DIR/extensions/highlight_html_cfg.py } | |
\end{Highlighting} | |
\end{Shaded} | |
\end{itemize} | |
For instance | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{nbconvert tst_highlights.ipynb --config ~/.local/share/jupyter/extensions/highlight_html_cfg.py } | |
\end{Highlighting} | |
\end{Shaded} | |
\subsection{LaTeX export}\label{latex-export} | |
This is a bit more complicated since the direct conversion removes all | |
html formatting present in markdown cells. Thus use again a | |
\textbf{preprocessor} which runs before the markdown \(\rightarrow\) | |
LaTeX conversion. In turn, it appears that we also need to postprocess | |
the result. | |
Three LaTeX commands, namely \emph{highlighta, highlightb, highlightc}, | |
and three environments \emph{highlightA, highlightB, highlightC} are | |
defined. Highlighting html markup is then transformed into the | |
corresponding LaTeX commands and the text for completely highlighted | |
cells is put in the adequate LaTeX environment. | |
Pre and PostProcessor classes are defined in the file | |
\texttt{pp\_highlighter.py} located in the \texttt{extensions} | |
directory. A LaTeX template, that includes the necessary packages and | |
the definitions of commands/environments is provides as | |
\texttt{highlighter.tplx} in the template directory. The template | |
inherits from \texttt{article.ltx}. For more complex scenarios, | |
typically if the latex template file has be customized, the user shall | |
modify its template or inherit from his base template rather than from | |
article. | |
Finally, a config file fixes the different options for the conversion. | |
Then the command to issue is simply | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{nbconvert FILE --config JUPYTER_DATA_DIR/extensions/highlight_latex_cfg.py } | |
\end{Highlighting} | |
\end{Shaded} | |
e.g. | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{jupyter} \NormalTok{nbconvert tst_highlights.ipynb --config ~/.local/share/jupyter/extensions/highlight_latex_cfg.py } | |
\end{Highlighting} | |
\end{Shaded} | |
\subsection{Configuring paths}\label{configuring-paths} | |
\highlighta{For those who do not have taken the extension from the | |
\texttt{jupyter_contrib_nbextensions} repository or have not configured | |
extensions via its \texttt{setup.py} utility,} a file | |
\texttt{set\_paths.py} is present in the extension directory (it is | |
merely a verbatim copy of the relevant parts in setup.py). This file | |
configure the paths to the \texttt{templates} and \texttt{extension} | |
directories. It should be executed by something like | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{python3} \NormalTok{set_paths.py} | |
\end{Highlighting} | |
\end{Shaded} | |
Additionaly, you may also have to execute \texttt{mv\_paths.py} if you | |
installed from the original repo via | |
\texttt{jupyter\ nbextension\ install\ ..} | |
\begin{Shaded} | |
\begin{Highlighting}[] | |
\KeywordTok{python3} \NormalTok{mv_paths.py} | |
\end{Highlighting} | |
\end{Shaded} | |
\subsection{Example for embedding the css within the notebook before | |
conversion}\label{example-for-embedding-the-css-within-the-notebook-before-conversion} | |
\begin{Verbatim}[commandchars=\\\{\}] | |
>>> \PY{k+kn}{from} \PY{n+nn}{IPython}\PY{n+nn}{.}\PY{n+nn}{core}\PY{n+nn}{.}\PY{n+nn}{display} \PY{k}{import} \PY{n}{display}\PY{p}{,} \PY{n}{HTML} | |
... \PY{k+kn}{from} \PY{n+nn}{jupyter\PYZus{}core}\PY{n+nn}{.}\PY{n+nn}{paths} \PY{k}{import} \PY{n}{jupyter\PYZus{}config\PYZus{}dir}\PY{p}{,} \PY{n}{jupyter\PYZus{}data\PYZus{}dir} | |
... \PY{k+kn}{import} \PY{n+nn}{os} | |
... \PY{n}{csspath}\PY{o}{=}\PY{n}{os}\PY{o}{.}\PY{n}{path}\PY{o}{.}\PY{n}{join}\PY{p}{(}\PY{n}{jupyter\PYZus{}data\PYZus{}dir}\PY{p}{(}\PY{p}{)}\PY{p}{,}\PY{l+s}{\PYZsq{}}\PY{l+s}{nbextensions}\PY{l+s}{\PYZsq{}}\PY{p}{,} | |
... \PY{l+s}{\PYZsq{}}\PY{l+s}{highlighter}\PY{l+s}{\PYZsq{}}\PY{p}{,}\PY{l+s}{\PYZsq{}}\PY{l+s}{highlighter.css}\PY{l+s}{\PYZsq{}}\PY{p}{)} | |
... \PY{n}{HTML}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{\PYZlt{}style\PYZgt{}}\PY{l+s}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{open}\PY{p}{(}\PY{n}{csspath}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{r}\PY{l+s}{\PYZdq{}}\PY{p}{)}\PY{o}{.}\PY{n}{read}\PY{p}{(}\PY{p}{)}\PY{o}{+}\PY{l+s}{\PYZsq{}}\PY{l+s}{\PYZlt{}/style\PYZgt{}}\PY{l+s}{\PYZsq{}}\PY{p}{)} | |
\end{Verbatim} | |
\begin{verbatim} | |
<IPython.core.display.HTML object> | |
\end{verbatim} | |
% Add a bibliography block to the postdoc | |
\end{document} | |