Skip to content

Commit

Permalink
Release Version v1.0 "refcard" Class (#1)
Browse files Browse the repository at this point in the history
* First version of the class "refcard"
  • Loading branch information
polyluxus authored Jan 20, 2020
1 parent 6943d60 commit 97b4c6f
Show file tree
Hide file tree
Showing 11 changed files with 1,642 additions and 10 deletions.
29 changes: 29 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
The current Maintainer is Martin C Schwarzer (polyluxus@gmail.com).

This class is mainly based on the Tex - Latex Stack Exchange question and answer:

Document Class for Reference Cards (https://tex.stackexchange.com/q/99765/33413).

It contains contributions from:

- Mike Renfro (https://tex.stackexchange.com/users/3345; https://github.com/mikerenfro)
- Sean Allred (https://tex.stackexchange.com/users/17423; https://github.com/vermiculus)
- Eric Berquist (https://github.com/berquist)

Other code has also been imported into this repository.
This is also highlighted in the commented source code.

- Part of the code is adapted from the answer of Werner (https://tex.stackexchange.com/users/5764):
How to create a command with key values? (https://tex.stackexchange.com/a/34314/33413)

- The automatically adjusting label width is based on the answers by user121799 (no stack exchange profile page)
and Gonzalo Medina (https://tex.stackexchange.com/users/3954)
Why conflict between mathtools and Gonzalo's solution for auto-adjusting description environment?
(https://tex.stackexchange.com/q/461056/33413)
Automatically set description list `labelwidth` based on widest label?
(https://tex.stackexchange.com/q/130097/33413)

- Expansion of column types in array tables is based on the code provided by Bruno Le Floch
(https://tex.stackexchange.com/users/2707).
How do I expand a macro into a tabular head? (https://tex.stackexchange.com/a/14460/33413)

173 changes: 173 additions & 0 deletions LICENSE.markdown

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# refcard

A reference card class for LaTeX2e.

According to [Wikipedia](https://en.wikipedia.org/wiki/Cheat_sheet),
a cheat sheet is a concise set of notes used for quick reference.
Some might even call it a [reference card or sheet](https://en.wikipedia.org/wiki/Reference_card),
hence the name.

This small class is aimed to make the typesetting of
reference cards a bit less tedious, so you can focus on using them.
The class is inspired from the question and answer
[Document Class for Reference Cards](https://tex.stackexchange.com/q/99765).

Since `refcard` is based on `article` most options can be passed on.

## Additional Options

* `columns=<num>` How many columns, default is 3.
* `margin=<length>` Passed to `geometry`, default 1 cm.

## Disabled Options

* `portrait` only supports `landscape`; ignored, warning.
* `titlepage` saving space, so no title page; ignored, warning.
* `twocolumn` class uses `multicol`; break, error.

## Features

* Dense settings to save maximum space.
* No enumeration of (sub)sections.
* Customised itemise environments.

## Acknowledgements

Thanks to the following people, who have contributed to the
original implementation:

- Mike Renfro ([Mike Renfro](https://tex.stackexchange.com/users/3345),
[mikerenfro](https://github.com/mikerenfro));
- Sean Allred ([Sean Allred](https://tex.stackexchange.com/users/17423),
[vermiculus](https://github.com/vermiculus));
- Eric Berquist, ([berquist](https://github.com/berquist)).

Currently maintained by Martin C Schwarzer ([Martin-マーチン](https://chemistry.stackexchange.com/users/4945),
[polyluxus](https://github.com/polyluxus)).


Other code has also been imported into this repository.
This is also highlighted in the commented source code.

- Part of the code is adapted from the answer of Werner ([Werner](https://tex.stackexchange.com/users/5764)):
[How to create a command with key values?](https://tex.stackexchange.com/a/34314/33413)

- The automatically adjusting label width is based on the answers by user121799 (no stack exchange profile page)
and Gonzalo Medina ([Gonzalo Medina](https://tex.stackexchange.com/users/3954)):
- [Why conflict between mathtools and Gonzalo's solution for auto-adjusting description environment?](https://tex.stackexchange.com/q/461056/33413)
- [Automatically set description list `labelwidth` based on widest label?](https://tex.stackexchange.com/q/130097/33413)

- Expansion of column types in array tables is based on the code provided by Bruno Le Floch
([Bruno Le Floch](https://tex.stackexchange.com/users/2707)):
[How do I expand a macro into a tabular head?](https://tex.stackexchange.com/a/14460/33413)

## License

The class is licensed [CC-BY-SA 4.0](LICENSE.markdown).

10 changes: 0 additions & 10 deletions README.md

This file was deleted.

Binary file added demo/documentation.pdf
Binary file not shown.
290 changes: 290 additions & 0 deletions demo/documentation.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
\documentclass[ % inherits article
final, % or
% draft,
a4paper, % or
% letterpaper % (etc. pp.)
% portrait, % WILL PRODUCE WARNING
columns=3, % this is the default
margin=1.0cm, % default, or
% margin=0.5in, % default
% titlepage, % WILL PRODUCE WARNING
% twocolumn % WOULD PRODUCE ERROR
]{refcard}

%
% Adapted from https://tex.stackexchange.com/a/99784.
%

% Fonts declaration
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{libertine}

% language

\usepackage[english]{babel}
\usepackage{csquotes}

% spacing for the letter
\usepackage{setspace}
% Typesetting code prettier
\usepackage[dvipsnames]{xcolor}
\definecolor{lightgray}{gray}{0.95}
\usepackage{listings}
\lstdefinestyle{mytex}{
language=[LaTeX]TeX,%
backgroundcolor=\color{lightgray},%
basicstyle=\footnotesize\ttfamily,%
keywordstyle=\bfseries,%
breaklines=true,%
morekeywords={part,chapter,subsection,subsubsection,paragraph,subparagraph}%
}

\lstset{style=mytex}

% Symbols for SE and GH
\usepackage{fontawesome}
% Symbols for creative commons
\usepackage{ccicons}
% linking to the outside world
\usepackage{hyperref}

% Please no font errors
% https://tex.stackexchange.com/a/9366/33413
\newcommand\mybackslash{\char`\\}

% What this is about
\title{Cheat sheet on \texttt{refcard}}
\author{Version 1.0} % I know, horrible abuse
\date{2020/01/18}

\begin{document}
\maketitle

\section{Introduction}

According to \href{https://en.wikipedia.org/wiki/Cheat_sheet}{Wikipedia},
a cheat sheet is a concise set of notes used for quick reference.
Some might even call it a \href{https://en.wikipedia.org/wiki/Reference_card}{reference sheet},
hence the name.
In lieu of a proper documentation, we provide herewith a
reference sheet for the document class \lstinline`refcard`.

This small class is aimed to make the typesetting of
reference sheets a bit less tedious, so you can focus on using them.
The class is inspired from the question and answer
\faStackExchange~\href{https://tex.stackexchange.com/q/99765}{Document Class for Reference Cards}.

Since \lstinline`refcard` is based on \lstinline`article` most options can be passed on.

\section{Additional Options}

\begin{refcardtable}[envcolumns=2,cellalign=l]
\lstinline`columns=<num>` & How many columns, default is 3.\\
\lstinline`margin=<length>` & Passed to \lstinline`geometry`, default 1~cm.
\end{refcardtable}

\section{Disabled Options}

\begin{refcardtable}
\lstinline`portrait` & only supports \lstinline`landscape`; ignored, warning.\\
\lstinline`titlepage` & saving space, so no title page; ignored, warning.\\
\lstinline`twocolumn` & class uses \lstinline`multicol`; break, error.\\
\end{refcardtable}

\section{Features}

\begin{itemize}
\item Dense settings to save maximum space.
\item No enumeration of \lstinline`(sub)section`s.
\item Customised itemise environments.
\end{itemize}

\section{Environments}

\subsection{Description based environments}

The environment \lstinline`refcardlist` is a description based list,
which means that the item is a string, for example to use as a command.
It automatically adjusts the width of the label to the longest one.
The label can be formatted by specifying \lstinline`labelfont=<command>`.

For example:
\begin{refcardlist}[labelfont=\ttfamily]
\item[Short] text text text
\item[A long label] text text text
\item[Shorter] text text text
\end{refcardlist}

\begin{lstlisting}
\begin{refcardlist}[labelfont=\ttfamily]
\item[Short] text text text
\item[A long label] text text text
\item[Shorter] text text text
\end{refcardlist}
\end{lstlisting}

\subsection{Inline description list}

With the environment \lstinline`refcardinline` the list will be
set as a single paragraph.
The label can be formatted by specifying \lstinline`labelfont=<command>`.
Items are joined by a semicolon (;) and the list is closed with a full stop (.).

For example:
\begin{refcardinline}[labelfont=\itshape]
\item[Short] text text text
\item[A long label] text text text
\item[Shorter] text text text
\end{refcardinline}

\begin{lstlisting}
\begin{refcardinline}[labelfont=\itshape]
\item[Short] text text text
\item[A long label] text text text
\item[Shorter] text text text
\end{refcardinline}
\end{lstlisting}

\subsection{Column assorted list}

The environment \lstinline`refcardcolumnlist` provides access to a list,
which is set in multiple columns.
The number of columns can be given as an optional argument,
in the form \lstinline`envcolumns=<INT>`
the default is to use two.

\begin{refcardcolumnlist}[envcolumns=5]
\item text
\item text
\item text
\item text
\item text
\item text
\item text
\item text
\item text
\end{refcardcolumnlist}

\begin{lstlisting}
\begin{refcardcolumnlist}
\begin{rscolslist}[envcolumns=5]
\item text
\item text
\item text
\item text
\item text
\item text
\item text
\item text
\item text
\end{refcardcolumnlist}
\end{lstlisting}

\subsection{Verbatim Code Fragments}

While it is often desired for these cheat sheets, it is not easily implemented.
For the time being, there is an environment which accepts \textquote{code}:
\lstinline`refcardverblist`.

\begin{refcardverblist}[envcolumns=3]
\item[\( \times \)] \lstinline|\times|
\item[\( \infty \)] \lstinline|\infty|
\item[\( \supset \)] \lstinline|\supset|
\item[\( \alpha \)] \lstinline|\alpha|
\item[\( \epsilon \)] \lstinline|\epsilon|
\end{refcardverblist}

\begin{lstlisting}
\begin{refcardverblist}[envcolumns=3]
\item[\( \times \)] \lstinline|\times|
\item[\( \infty \)] \lstinline|\infty|
\item[\( \supset \)] \lstinline|\supset|
\item[\( \alpha \)] \lstinline|\alpha|
\item[\( \epsilon \)] \lstinline|\epsilon|
\end{refcardverblist}
\end{lstlisting}

It is (currently) not possible to use the verbatim string as a label.
If this is desired, switch to a tabular based environment, which is described below.

\subsection{Table based environments}

The table based environments use the \lstinline`tabularx` package,
where the row of the table will fill the whole line.

The first one is \lstinline`refcardtable`.
The number of columns can be changed in the optional argument, but defaults to two,
e.g. \lstinline`envcolumns=<INT>`. The alignment of the columns can be changed
with \lstinline`cellalign=<r|l|c|X>`.
The last column, however, is special, because it is used to balance the table and
therefore the column type is fixed as \lstinline`X`.

As mentioned before, strings to be handled verbatim can be placed in this environment,
see row 3

\begin{refcardtable}[envcolumns=3,cellalign=c]
\hline
Short & 1 & text text text\\
A long label & 2 & text text text\\
\lstinline|Shorter| & 3 & %
text \lstinline|text| text\\\hline
\end{refcardtable}

\begin{lstlisting}
\begin{refcardtable}[envcolumns=3,cellalign=c]
\hline
Short & 1 & text text text\\
A long label & 2 & text text text\\
\lstinline|Shorter| & 3 & %
text \lstinline|text| text\\\hline
\end{refcardtable}
\end{lstlisting}



The second one is meant to be used for maths notation,
called \lstinline`rsmathtable`, which has no argument.
The first column is set in display style maths mode and
will be fitted to the widest entry.
The second column is meant for the description and
like the table before, the type is fixed as \lstinline`X`.

\begin{refcardmathtable}
pV = nRT & Ideal gas law \\
0 = e^{i\pi} + 1 & Euler's identity \\
\log(MN) = \log(M) + \log(N) & %
Logarithm addition rule\\
\end{refcardmathtable}


\begin{lstlisting}
\begin{refcardmathtable}
pV = nRT & Ideal gas law \\
0 = e^{i\pi} + 1 & Euler's identity \\
\log(MN) = \log(M) + \log(N) & %
Logarithm addition rule\\
\end{refcardmathtable}
\end{lstlisting}

\section{Acknowledgments}

Thanks to the following people, who have contributed to the original implementation:
\begin{refcardinline}
\item[Mike Renfro] %
\href{https://tex.stackexchange.com/users/3345}{\faStackExchange}
\href{https://github.com/mikerenfro}{\faGithub}
\item[Sean Allred]
\href{https://tex.stackexchange.com/users/17423}{\faStackExchange}
\href{https://github.com/vermiculus}{\faGithub}
\item[Eric Berquist]
\href{https://github.com/berquist}{\faGithub}
\item[] please see the manual for a full list.
\end{refcardinline}

Currently maintained by Martin C Schwarzer \href{https://chemistry.stackexchange.com/users/4945}{\faStackExchange}
\href{https://github.com/polyluxus}{\faGithub}.

The class and the document are licensed \ccbysa.

\end{document}
Binary file added doc/latex/refcard.pdf
Binary file not shown.
Loading

0 comments on commit 97b4c6f

Please sign in to comment.