I am new to MathJax. My software uses MathJax and takes LaTex-like input. I am used to of using Latex commands, like [latex]\frac{2}{3}\times x^2[/latex], but I cant use any of the Latex packages to get my task done. How is strikethrough text done? In Latex it requires use of packages and there is no base command for that. Any help will be appreciated.
Related
I use VSCode to write LaTeX using the LaTeX-Workshop VSCode extension, MiKTeX, and pdflatex. The LaTeX-Workshop extension comes with the handy feature of being able to hover packages and view their documentation, but I noticed that this feature does not work on the tikz package.
Screenshot with more detail.
I started looking into why this was the case, as the ctan page linked had this long and very detailed manual for TikZ and PGF. It turns out that MiKTeX does not even list a package called TikZ, which is confusing as my .tex files seem to compile fine when including the line \usepackage{tikz}, whereas attempting to use any other 'nonexistent' package would result in a compilation error.
I've gone through half a dozen webpages trying to understand what PGF and TikZ are in more detail, but it is very confusing. The ctan PGF page says "PGF is a macro package for creating graphics... that comes with a user-friendly syntax layer called TikZ", but I'm a little confused about what that means. Why would the package and syntax have different names?
My questions can be summed up as:
What exactly is PGF and TikZ? What's the difference between the two and is there a reason why they have different names?
How does my LaTeX compiler interpret "\usepackage{tikz}" if I don't have a package by that name installed?
What are TikZ libraries and what do lines like "\usetikzlibrary{arrows}" do exactly? Are they basically the same as packages?
If I'm using MiKTeX, where are the TikZ Libraries stored on my machine (Windows 10)? I have been able to find most other packages and their documentation within subfolders of "C:\Users\{USERNAME}\AppData\Local\Programs\MiKTeX 2.9\".
Instructions on how to link the TikZ/PGF manual pdf to MiKTeX so I can easily access the documentation in VSCode would be nice, but that is not really the focus of this post.
For clarification, I am not looking for a tutorial on how to use PGF/TikZ (there are many other good resources for that), nor am I looking for an overly high-level answer like "PGF/TikZ is a LaTeX package for creating graphics" that don't provide any more detail, I know that much already.
Pre-remark:
There are two slightly different usages for the word "package" in the latex world, one is the traditional \usepackage{....} you know from your latex document, the other is the ctan/miktex/texlive package. Most of the time, a ctan/miktex/texlive package simply contains the latex package of the same name, but sometimes it can have a different name and/or contain multiple latex packages at once.
What exactly is PGF and TikZ? What's the difference between the two and is there a reason why they have different names?
pgf provides the low level commands, like strokes etc. and tikz builds on top of this and uses the low level pgf commands to draw more complicate things, like geometrical shapes or rubber ducks (shameless plug)
This division between the low level and high level code is very useful, because it allows the user to load just as much as necessary. Take for example the beamer class. It uses all kinds of low level pgf commands to draw decorations on the slides, so it loads (parts of) the pgf package. It does not need all the fancy stuff from the tikz package, so it does not load it, which safes tons of time, because loading all of tikz is relativity slow.
How does my LaTeX compiler interpret "\usepackage{tikz}" if I don't have a package by that name installed?
You do have it installed, it is contained in the ctan/miktex/texlive pgf package. \usepackage{tikz} basically translates to \input{tikz.sty}. This file in return will load the latex pgf package (and many other things)
What are TikZ libraries and what do lines like "\usetikzlibrary{arrows}" do exactly? Are they basically the same as packages?
yes, they are basically packages for tikz with which you can extend the capabilities of tikz even further.
If I'm using MiKTeX, where are the TikZ Libraries stored on my machine (Windows 10)? I have been able to find most other packages and their documentation within subfolders of "C:\Users\{USERNAME}\AppData\Local\Programs\MiKTeX 2.9\".
You can look this up yourself in your .log file. Search it for tikz.sty and this and the following lines will tell you the location of all the files.
Instructions on how to link the TikZ/PGF manual pdf to MiKTeX so I can easily access the documentation in VSCode would be nice, but that is not really the focus of this post.
If you open a new terminal in vscode (ctrl+shift+`), you can open the user guide by typing texdoc tikz or texdoc pgf (same file, just multiple ways to open it)
Is it possible to use plantUML inside a latex document?
One workaround would be to convert plantUML into tikzpicture and integrate it in the latex document. That seems a bit too much effort to me, especially with updates.
I am using overleaf and TeXiFy, the document generation should work on both latex editors.
If a direct integration is possible, I would like to see an example.
thanks
The original question can be subdivided into the four separate yet closely related questions:
How is LaTeX in markdown displayed in JupyterLab?
How is LaTeX in markdown exported (into supported file formats) in JupyterLab?
How can I define new LaTeX macros (in order to avoid repetition) and have them properly displayed and exported in JupyterLab?
How can I use packages from CTAN, the official package registry of TeX packages, and have them properly displayed and exported in JupyterLab?
The questions 3. and 4. are of utter importance for me because I won't be able to switch out of LaTeX unless I can define macros in JupyterLab and my papers will be less readable unless I have certain packages from CTAN. The first two questions are asked because they can greatly assist answering questions 3. and 4.
First question ("How is LaTeX in markdown displayed in JupyterLab?")
According to the official documentation,
JupyterLab is the next-generation web-based user interface for Project Jupyter.
Indeed, when I type in the console
jupyter lab
and hit enter, as a user I can see that a browser tab opens up and there I can start working on my files.
As a developer, I understand that there is a server running in the background that handles requests from the browser by interacting with tools of Project Jupyter and serving HTML, CSS, JS, WASM, JPG, and other files to my browser.
When as a user I proceed to open a Jupyter Notebook (.ipynb document) with some LaTeX code in markdown cells, instead of the source code
Let $\nu_p(n)$ denote p-adic order for prime number $p$ of non-zero integer $n$ where $\nu_p$ is a p-adic order function,
$$
\begin{cases}
\nu_p : \mathbb{Z} \setminus \{ 0 \} \to \mathbb{N}_0; \\
\nu_p = n \mapsto max\{ e \in \mathbb{N}_0. p^e \vert n \};
\end{cases}
$$
I can see the rendered output,
What I mean by "How is LaTeX in markdown displayed in JupyterLab?"
Which tools (not necessarily of Project Jupyter) are used and how do they work together in order to display the rendered output?
What's the role of the kernel (evcxr for Rust or IPython for Pyhton) in this process? Is the kernel involved in it?
Are there any config files that are being read in the process regardless of the kernel?
Second question ("How is LaTeX in markdown exported (into supported file formats) in JupyterLab?")
While in a tab with that Jupyter Notebook (.ipynb document) with some LaTeX code in markdown cells, I can click "File" > "Save and Export Notebook As..." and then select one of the supported formats
Once I select one of the format, first a new tab opens up
then after a while the tab will be closed and the exported file will finally be installed
What I mean by "How is LaTeX in markdown exported (into supported file formats) in JupyterLab?"
Similarly to the first question,
Which tools (not necessarily of Project Jupyter) are used and how do they work together in order to export the Notebook with some LaTeX in a Markdown cell?
What's the role of the kernel (evcxr for Rust or IPython for Pyhton) in this process? Is the kernel involved in it?
Are there any config files that are being read in the process regardless of the kernel?
Third question ("How can I define new LaTeX macros (in order to avoid repetition) and have them properly displayed and exported in JupyterLab?")
As far as I understand, JupyterLab serves pages with MathJax for displaying LaTeX in Markdown and MathJax allows to declare TeX macros. Unless the tools that perform conversion to other file formats cannot work with LaTeX (which is an approximate superset of LaTeX supported by MathJax), it should be relatively straightforward to support custom macros at least through a config file.
Fourth question ("How can I use packages from CTAN, the official package registry of TeX packages, and have them properly displayed and exported in JupyterLab?")
MathJax doesn't support \usepackage{} out of the box. However, I suspect that it must be possible to preprocess the contents of the cell before displaying it. And then I can provide an alternative definitions (for displaying but not the exporting) for macros from CTAN packages.
Notes
I understand that I can insert pages from an existing PDF in LaTeX. However, it is inconvenient.
Every time I need to copy a latex paragraph and put it in my source code as a doxygen documentation, I need to put a \f next to each $ and do other modifications.
Isn't there an easier way to tell doxygen that this whole paragraph contains only latex and thus should be fully interpreted as latex code?
Thanks in advance.
It appears not to be possible to include LaTeX format .tex files directly. Depending on the complexity of the LaTeX files, a possibility would be to write a script which makes the required modifications. Related questions that give further background and suggestions are How to include LaTeX snippets directly in Doxygen comments and Including LaTeX documentation as comments in source code. Please come back and answer if you find a good solution to this problem.
I'd like to create multiple documents (output as PDFs after running pdflatex) whose source is from one file.
Example:
\documentclass{article}
\begin{document}
This text will appear in the first PDF.
\end{document}
\begin{document}
This text will appear in the second PDF.
\end{document}
This would be particularly useful because:
I could keep everything in 1 file, with a single, consistent preamble.
I could use ifthen or other loops to automatically generate various alternative forms of a document.
AFAIK this is not possible without some preprocessing of your file, i.e. using a scripting language to produce two separate documents then compiling them separately. Even then I don't think it's a good idea.
The first reason you think this would be useful is handled by putting your preamble in a separate document that is included in as many documents as you want using \include. The second aspect can be handled by using Makefiles and putting the conditional branching to build particular versions of a document in there.
I wrote a really simple preprocessor for LaTeX that embeds Ruby code directly into .tex files for this purpose and use the ERB template engine. Here's the source code on Google Code, if you want to take a look. There's not much to it, though I regularly use it from a Ant/latexmk-based build script and it has proved very useful for generating multiple version of my résumé. It works equally well on Linux/Mac OS X/Windows, assuming you have a working LaTex and Ruby installation.