Created
February 18, 2020 05:04
-
-
Save wircho/03dd3d3d94f63e8c3b0adcbca5b531b5 to your computer and use it in GitHub Desktop.
LaTeX template for a single formula.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[10pt]{article} | |
\pagestyle{empty} | |
\setlength{\topskip}{0pt} | |
\setlength{\parindent}{0pt} | |
\setlength{\abovedisplayskip}{0pt} | |
\setlength{\belowdisplayskip}{0pt} | |
\usepackage[T1]{fontenc} | |
\usepackage{geometry} | |
\usepackage{xstring} | |
\usepackage{amsmath} | |
\newsavebox{\snippetbox} | |
\newlength{\snippetwidth} | |
\newlength{\snippetheight} | |
\newlength{\snippetdepth} | |
\newlength{\pagewidth} | |
\newlength{\pageheight} | |
\newlength{\pagelmargin} | |
\newlength{\pagetmargin} | |
\newlength{\pagermargin} | |
\newlength{\pagebmargin} | |
\begin{lrbox}{\snippetbox} | |
$\displaystyle F_n=\frac{\left(1+\sqrt{5}\right)^n-\left(1-\sqrt{5}\right)^n}{2^n\sqrt{5}}$ | |
\end{lrbox} | |
\settowidth{\snippetwidth}{\usebox{\snippetbox}} | |
\settoheight{\snippetheight}{\usebox{\snippetbox}} | |
\settodepth{\snippetdepth}{\usebox{\snippetbox}} | |
\setlength\pagelmargin{4pt} | |
\setlength\pagetmargin{4pt} | |
\setlength\pagermargin{4pt} | |
\setlength\pagebmargin{4pt} | |
\setlength\pagewidth\snippetwidth | |
\addtolength\pagewidth\pagelmargin | |
\addtolength\pagewidth\pagermargin | |
\setlength\pageheight\snippetheight | |
\addtolength{\pageheight}{\snippetdepth} | |
\addtolength\pageheight\pagetmargin | |
\addtolength\pageheight\pagebmargin | |
\newwrite\foo | |
\immediate\openout\foo=\jobname.json | |
% https://latex.org/forum/viewtopic.php?t=5180 | |
\begingroup | |
\catcode`\[ = 1\relax | |
\catcode`\] = 2\relax | |
\catcode`\{ = 12\relax | |
\catcode`\} = 12 \relax | |
\gdef\OpenBrace[{] | |
\gdef\CloseBrace[}] | |
\endgroup | |
\immediate\write\foo{\OpenBrace} | |
\immediate\write\foo{ "snippetdepth": "\the\snippetdepth",} | |
\immediate\write\foo{ "snippetheight": "\the\snippetheight",} | |
\immediate\write\foo{ "snippetwidth": "\the\snippetwidth",} | |
\immediate\write\foo{ "pagewidth": "\the\pagewidth",} | |
\immediate\write\foo{ "pageheight": "\the\pageheight",} | |
\immediate\write\foo{ "pagelmargin": "\the\pagelmargin",} | |
\immediate\write\foo{ "pagermargin": "\the\pagermargin",} | |
\immediate\write\foo{ "pagetmargin": "\the\pagetmargin",} | |
\immediate\write\foo{ "pagebmargin": "\the\pagebmargin"} | |
\immediate\write\foo{\CloseBrace} | |
\closeout\foo | |
\geometry{paperwidth=\pagewidth,paperheight=\pageheight,lmargin=\pagelmargin,tmargin=\pagetmargin,rmargin=\pagermargin,bmargin=\pagebmargin} | |
\begin{document} | |
\usebox{\snippetbox} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment