Skip to content

Instantly share code, notes, and snippets.

@jrbrodie77
Last active January 20, 2022 18:19
Show Gist options
  • Select an option

  • Save jrbrodie77/05b12588ffa5a961a4305c36126d0c7a to your computer and use it in GitHub Desktop.

Select an option

Save jrbrodie77/05b12588ffa5a961a4305c36126d0c7a to your computer and use it in GitHub Desktop.
High Density OrgMode LaTeX Export Class
#+TITLE: Exporting orgmode files in high density cheatsheet format.
#+AUTHOR: John Brodie
#+EMAIL: john.brodie@gmail.com
#+DATE: 2022-01-20
#+LATEX_CLASS: cheatsheet
#+LATEX: \begin{multicols*}{3}
#+LATEX: \raggedbottom
#+LATEX: \small
#+OPTIONS: p:t
# ^ option ignores latex underscore _
#+OPTIONS: ^:nil
* High Density "Cheat Sheet" orgmode export.
I occasionally like to print a one page list of my project TODOS and notes.
The aim of this format is not maximum clarity, it is high density.
The title, author and date are _not printed_, this behavior can be modified in
the .cls file.
* Setup
** LaTeX Setup
I put the file cheatsheet.cls in location:
: ~/latex/cheatsheet/cheatsheet.cls
In .zshrc (or .bashrc etc.) set the env var that controls LaTeX search path:
: export TEXINPUTS=.:$HOME/latex//:
Note: this syntax is very touchy, took me a few tries with trailing slashes etc.
before it worked.
** Emacs Setup
Emacs needs a mapping between LATEX_CLASS and the LaTeX .cls
file, and also how to map orgmode headings to latex headings.
#+begin_example
(add-to-list 'org-latex-classes
'("cheatsheet"
"\\documentclass{cheatsheet}[10pt,letterpaper]
\\tolerance=1000
[NO-DEFAULT-PACKAGES]
[EXTRA]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
#+end_example
The actual *cheatsheet.cls* file can either live in the same path as the .org
file, or added to the Latex search path by...
** Latex Class
The file
** Latex Header in .org File
The .org file has the lines below in the header. These lines are in the .org
file because I couldn't find an easy way to have the org export process add them
in based on templates, classes etc.
#+begin_example
#+LATEX_CLASS: cheatsheet
#+LATEX: \begin{multicols*}{3}
#+LATEX: \raggedbottom
#+LATEX: \small
#+OPTIONS: p:t
#+OPTIONS: ^:nil
#+OPTIONS: *:nil
#+end_example
* Heading 1 - High Density Output Orgmode Class
** TODO Todos are printed with dates. Controlling the format of the dates is hardcoded into orgmode, so I didn't make them perfect. There is an annoying hanging linebreak!
DEADLINE: <2022-01-28 Fri> SCHEDULED: <2022-01-20 Thu>
** Heading 2
- [ ] Checkbox 1
- [ ] Checkbox 2
*** Heading 3
**** Heading 4
This is texts at heading 4, which may run deeper than the levels of sections
supported by the latex class.
* APPENDIX: RICHARD FEYNMAN ON EXAMPLES
<<feynman-examples>>
The below quotes from Richard Feynman in "Surely You're Joking, Mr.
Feynman!" I knew Richard Feynman well, from the age of 9, and spent as
much time with him as I could. He had a peculiar way of thinking, and
I very consciously copied his method. The gist of it is to always look
at examples, then tweak them. Turn them upside down, inside out,
left-to-right, and keep pushing till they go wrong, then force yourself
to understand why. This practice forces the brain to recognize all kinds
of wrongness quickly and to stay out of mind traps.
So you should do with \belex. Study the examples, then push on them
until they break. Make sure you understand and can back out. Of course,
this is a variation of the methodology of Test-Driven Development, very
important for programmer productivity.
#+begin_quote
That was the first time I was in Japan. I was eager to go back, and said
I would go to any university they wanted me to. So the Japanese arranged
a whole series of places to visit for a few days at a time.
At all these places everybody working in physics would tell me what they
were doing and I'd discuss it with them. They would tell me the general
problem they were working on, and would begin to write a bunch of
equations.
"Wait a minute," I would say. "Is there a particular example of this
general problem?"
"Why yes; of course."
*"Good. Give me one example." I can't understand anything in general unless I'm carrying along in my mind a specific example and watching it go. Some people think in the beginning I'm kind of slow and I don't understand the problem, because I ask a lot of these "dumb" questions.*
But later, when the guy's in the middle of a bunch of equations, he'll
say something and I'll say "Wait a minute! There's an error! That can't
be right!"
The guy looks at his equations, and sure enough, after a while he finds
the mistake and wonders, "How the hell did this guy, who hardly
understood anything at the beginning, find that mistake in the mess of
all these equations?"
He thinks I'm following the steps mathematically, but that's not what
I'm doing. I have the specific example of what he's trying to analyze,
and I know from instinct and experience the properties of the thing. So
when the equation says it should behave so-and-so, and I know that's the
wrong way around, I jump up and say "Wait! There's a mistake!"
#+end_quote
% NOTE: remove the z_ from the name of this file, that is there to control the order of appearance in the gist.
% This class is a modification of a cheatsheet class on github
% https://github.com/kenfehling/latex-cheatsheet
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cheatsheet}
\LoadClassWithOptions{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,arrows,fit,calc,graphs,graphs.standard}
\usepackage[nosf]{kpfonts}
\usepackage[t1]{sourcesanspro}
\usepackage{multicol}
\usepackage{wrapfig}
\usepackage[top=5mm,bottom=10mm,left=5mm,right=5mm,landscape]{geometry}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{microtype}
\usepackage{hyperref}
\usepackage{pdfpages}
\usepackage{enumitem}
\usepackage{lipsum}
\let\bar\overline
\setlength{\itemsep}{1pt}
% Itemize is used to eliminate spacing above and below list items.
% See latex docs on itemize package for details.
\setlist[itemize]{leftmargin=*,nosep,topsep=0pt}
\definecolor{myblue}{cmyk}{1,.72,0,.38}
\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(0:2cm) circle (1.5cm)}
\colorlet{circle edge}{myblue}
\colorlet{circle area}{myblue!5}
\tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
outline/.style={draw=circle edge, thick}}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\everymath\expandafter{\the\everymath \color{myblue}}
\everydisplay\expandafter{\the\everydisplay \color{myblue}}
\renewcommand{\baselinestretch}{.8}
\pagestyle{empty}
\global\mdfdefinestyle{header}{%
linecolor=gray,linewidth=1pt,%
leftmargin=0mm,rightmargin=0mm,skipbelow=0mm,skipabove=0mm,
}
\makeatletter % Author: https://tex.stackexchange.com/questions/218587/how-to-set-one-header-for-each-page-using-multicols
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
{.7ex}%
{.4ex}%x
{\color{myblue}\sffamily\small\bfseries\MakeUppercase}}
\renewcommand{\subsection}{\@startsection{subsection}{1}{0mm}%
{.7ex}%
{.4ex}%x
{\sffamily\small\MakeUppercase}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{1}{0mm}%
{.7ex}%
{.4ex}%x
{\sffamily\small\MakeUppercase}}
\makeatother
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment