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

Latex macros in Jupyter Lab #207

Open
xt0r3-Cambridge opened this issue Jan 30, 2023 · 1 comment
Open

Latex macros in Jupyter Lab #207

xt0r3-Cambridge opened this issue Jan 30, 2023 · 1 comment

Comments

@xt0r3-Cambridge
Copy link

xt0r3-Cambridge commented Jan 30, 2023

          So this would work?
<div hidden>
\newcommand{\require}[1]{}

$\require{begingroup}\require{newcommand}$
$\gdef\vec#1{\boldsymbol{#1}}$

\vskip-\parskip
\vskip-\baselineskip

</div>

Originally posted by @jasongrout in jupyterlab/jupyterlab#5997 (comment)

The above approach did not work for me when trying to export as PDF.

I have since tried many other approaches, and the one that happened to work by some miracle is this:

<div hidden>
\[
\iffalse \textrm{General purpose macros} \fi
\renewcommand{\deg}{{^{\circ}}}
\newcommand{\rbr}[1]{{\left({{#1}}\right)}}
\newcommand{\abr}[1]{{\left\langle{{#1}}\right\rangle}}
\newcommand{\cbr}[1]{{\left\{{{#1}}\right\}}}
\newcommand{\sbr}[1]{{\left[{{#1}}\right]}}
\newcommand{\pipe}[1]{{\left|{{#1}}\right|}}
\newcommand{\ppipe}[1]{{\left\|{{#1}}\right\|}}
\newcommand{\floor}[1]{{\left\lfloor{{#1}}\right\rfloor}}
\newcommand{\ceil}[1]{{\left\lceil{{#1}}\right\rceil}}
\newcommand{\set}[1]{{ \cbr{{#1}} }}
\iffalse \textrm{Semantics macros} \fi
\newcommand{\iet}[3]{{\textrm{if } {{#1}} \textrm{ then } {{#2}} \textrm{ else } {{#3}}}}
\renewcommand{\t}[1]{{\textrm{true}}}
\newcommand{\f}[1]{{\textrm{false}}}
\iffalse \textrm{Compiler Construction macros} \fi
\newcommand{\fst}[1]{{\textrm{FIRST}({{#1}})}}
\newcommand{\flw}[1]{{\textrm{FOLLOW}({{#1}})}}
\newcommand{\gen}[2][]{{ {{#1}} \implies {{#2}} }} 
\]
</div>

I have no idea why this works and the other approaches don't, but in case anyone is looking for a quick and dirty fix, there you go.
Also, note that there can be no line breaks between the lines or this won't work.

You will need to shut down the notebook and restart it after adding the macros and it should work.

@welcome
Copy link

welcome bot commented Jan 30, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

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

1 participant