diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..65181d1 --- /dev/null +++ b/CONTRIBUTORS @@ -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) + diff --git a/LICENSE.markdown b/LICENSE.markdown new file mode 100644 index 0000000..f3b1110 --- /dev/null +++ b/LICENSE.markdown @@ -0,0 +1,173 @@ +## creative commons + +# Attribution-ShareAlike 4.0 International + +Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. + +### Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. + +* __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors). + +* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). + +## Creative Commons Attribution-ShareAlike 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. + +### Section 1 – Definitions. + +a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. + +b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. + +c. __BY-SA Compatible License__ means a license listed at [creativecommons.org/compatiblelicenses](http://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License. + +d. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. + +e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. + +f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. + +g. __License Elements__ means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike. + +h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License. + +i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. + +j. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License. + +k. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. + +l. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. + +m. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. + +### Section 2 – Scope. + +a. ___License grant.___ + + 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: + + A. reproduce and Share the Licensed Material, in whole or in part; and + + B. produce, reproduce, and Share Adapted Material. + + 2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. + + 3. __Term.__ The term of this Public License is specified in Section 6(a). + + 4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. + + 5. __Downstream recipients.__ + + A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. + + B. __Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply. + + C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. + + 6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). + +b. ___Other rights.___ + + 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this Public License. + + 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. + +### Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following conditions. + +a. ___Attribution.___ + + 1. If You Share the Licensed Material (including in modified form), You must: + + A. retain the following if it is supplied by the Licensor with the Licensed Material: + + i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of warranties; + + v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + + B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and + + C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. + + 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. + +b. ___ShareAlike.___ + +In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. + +1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. + +2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. + +3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. + +### Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: + +a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; + +b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and + +c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. + +### Section 5 – Disclaimer of Warranties and Limitation of Liability. + +a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__ + +b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__ + +c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. + +### Section 6 – Term and Termination. + +a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. + +b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. + +c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. + +d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + +### Section 7 – Other Terms and Conditions. + +a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. + +b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. + +### Section 8 – Interpretation. + +a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. + +b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. + +c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. + +d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. + +> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the [CC0 Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/legalcode). Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. +> +> Creative Commons may be contacted at creativecommons.org. diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..76fb638 --- /dev/null +++ b/README.markdown @@ -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=` How many columns, default is 3. + * `margin=` 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). + diff --git a/README.md b/README.md deleted file mode 100644 index 82fd5dc..0000000 --- a/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# 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 class is still in development. diff --git a/demo/documentation.pdf b/demo/documentation.pdf new file mode 100644 index 0000000..7f882ed Binary files /dev/null and b/demo/documentation.pdf differ diff --git a/demo/documentation.tex b/demo/documentation.tex new file mode 100644 index 0000000..83ceeba --- /dev/null +++ b/demo/documentation.tex @@ -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=` & How many columns, default is 3.\\ + \lstinline`margin=` & 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=`. + +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=`. +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=` +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=`. The alignment of the columns can be changed +with \lstinline`cellalign=`. +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} diff --git a/doc/latex/refcard.pdf b/doc/latex/refcard.pdf new file mode 100644 index 0000000..cd6c359 Binary files /dev/null and b/doc/latex/refcard.pdf differ diff --git a/source/latex/.gitignore b/source/latex/.gitignore new file mode 100644 index 0000000..833dd35 --- /dev/null +++ b/source/latex/.gitignore @@ -0,0 +1,4 @@ +* +!.gitignore +!refcard.dtx +!refcard.ins diff --git a/source/latex/refcard.dtx b/source/latex/refcard.dtx new file mode 100644 index 0000000..83ec2fe --- /dev/null +++ b/source/latex/refcard.dtx @@ -0,0 +1,807 @@ +% \iffalse meta-comment +% +% This work is licensed under the +% +% Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0) +% +% To view a copy of this license, visit +% +% https://creativecommons.org/licenses/by-sa/4.0/ +% +% Repository: +% +% https://github.com/polyluxus/refcard +% +% Current Maintainer: +% +% Martin C Schwarzer +% +% For a list of contributers see the manual, or +% +% https://github.com/polyluxus/refcard/CONTRIBUTORS +% +% This work consists of the files refcard.dtx and refcard.ins +% and the derived filebase refcard.cls. +% +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{refcard.dtx} +% +%\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%\ProvidesClass{refcard} +%<*class> + [2020/01/20 v1.0 Reference Card Class] +% +% +%<*driver> +\documentclass{ltxdoc} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} +\usepackage{libertine} +\usepackage[english]{babel} +\usepackage{csquotes} +\usepackage{setspace} +\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} +\usepackage{fontawesome} +\usepackage{ccicons} +\usepackage{hyperref} +\newcommand\mybackslash{\char`\\} +\usepackage{dtxdescribe} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{refcard.dtx} + \PrintChanges + \PrintIndex +\end{document} +% +% \fi +% +% \CheckSum{176} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{v1.0}{2020/01/20}{Initial Version} +% +% \GetFileInfo{refcard.dtx} +% +% \DoNotIndex{\newcommand,\newenvironment} +% +% +% \providecommand*{\url}{\texttt} +% \title{The \textsf{refcard} class} +% \author{Martin C Schwarzer \\ \url{polyluxus@gmail.com}} +% \date{\fileversion~from \filedate} +% +% \maketitle +% +% \tableofcontents +% +% \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 (see further below). +% +% \section{Usage} +% +% After you have obtained and installed the class file you can load the class directly: +% +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +\documentclass{refcard} +[...] +\begin{document} +[...] +\end{document} +\end{lstlisting} +% \iffalse +% +% \fi +% +% \subsection{Class Option and disabled options} +% +% There are currently two options provided for this class: +% +% \DescribeKey[class]{columns} +% The columns option specifies the number of columns which sshall be used. +% For this purpose the \lstinline`multicol` package is loaded, and the begin and end +% document hooks are ammended. If not specified, it defaults to three columns. +% +% \DescribeKey[class]{margin} +% The margin option lets you specify a uniform margin used for the reference card. +% This length will be passed on to the \lstinline`geometry` package. +% If not specified, it defaults to 1~cm. +% +% There are three options disabled, as they might clash with this class: +% +% \DescribeKey[disabled]{portrait} +% Reference cards are usually set in landscape format; therefore this option is ignored and +% will produce a warning. +% +% \DescribeKey[disabled]{titlepage} +% Since the reference card should consist of two pages at most, there is no titlepage provided. +% This option is ignored and will result in a warning. +% +% \DescribeKey[disabled]{twocolumn} +% The class uses the \lstinline`multicol` package as described above. +% If this option is specified, an error will result. +% To achieve the same effect, specify \lstinline`columns=2` while loading the class. +% % +% \subsection{Redefinitions} +% +% The class redefines itemise environments to reduce the spacing around them. +% It also removes page numbers and numbers from sections. +% \DescribeMacro{\maketitle} +% The \lstinline`\maketitle` command has also been modified to produce a dense header. +% +% +% \subsection{New Environments} +% +% The environments accept optional arguments in the form of key-value pairs. +% +% \DescribeKey[Env]{labelfont} +% In description based environments the label font can be adjusted with e.g. \lstinline`labelfont=\ttfamily`. +% +% \DescribeKey[Env]{envcolumns} +% In column based environments the number of columns can be set with e.g. \lstinline`envcolumns=2`. +% +% \DescribeKey[Env]{cellalign} +% In table based environments the alignment of the cells can be adjusted with e.g. \lstinline`cellalign=c`. +% The last column of a table is always fixed, see the environment descriptions below. +% +% \subsubsection{Description-based Environments} +% +% \DescribeEnv{refcardlist} +% 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=`. +% +% \iffalse +%<*example> +% \fi +\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} +% \iffalse +% +% \fi +% +% \DescribeEnv{refcardinline} +% With the environment \lstinline`refcardinline` the list will be +% set as a single paragraph. +% The label can be formatted by specifying \lstinline`labelfont=`. +% Items are joined by a semicolon (;) and the list is closed with a full stop (.). +% +% \iffalse +%<*example> +% \fi +\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} +% \iffalse +% +% \fi +% +% \DescribeEnv{refcardcolumnlist} +% 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=` +% +% \iffalse +%<*example> +% \fi +\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} +% \iffalse +% +% \fi +% +% \DescribeEnv{refcardverblist} +% 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`. +% +% \iffalse +%<*example> +% \fi +\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} +% \iffalse +% +% \fi +% +% 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. +% +% \subsubsection{Table based environments} +% +% The table based environments use the \lstinline`tabularx` package, +% where the row of the table will fill the whole line. +% +% \DescribeEnv{refcardtable} +% 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=`. The alignment of the columns can be changed +% with \lstinline`cellalign=`. +% 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. +% +% \iffalse +%<*example> +% \fi +\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} +% \iffalse +% +% \fi +% +% \DescribeEnv{refcardmathtable} +% The second one is meant to be used for maths notation, +% called \lstinline`refcardmathtable`, 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`. +% +% \iffalse +%<*example> +% \fi +\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} +% \iffalse +% +% \fi +% +% \section{Example Files} +% +% A documentation in reference card style can be found as an example in the GitHub repository +% in the demo directory. +% +% \section{Contributing and Issues} +% +% If you find something not working, or are missing features, you are welcome to raise an issue on +% \href{https://github.com/polyluxus/refcard/issues}{\faGithub{}GitHub/polyluxus/refcard} or +% send a pull request. +% +% \section{License} +% +% This work is licensed under the \ccbysa +% Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0). +% To view a copy of this license, visit +% +% \begin{center} +% \href{https://creativecommons.org/licenses/by-sa/4.0/}{https://creativecommons.org/licenses/by-sa/4.0/}. +% \end{center} +% +% The full repository is located at +% +% \begin{center} +% \href{https://github.com/polyluxus/refcard}{https://github.com/polyluxus/refcard}. +% \end{center} +% +% The current Maintainer is Martin C Schwarzer (polyluxus@gmail.com). +% +% This class is mainly based on the Tex - Latex Stack Exchange question and answer: +% +% \begin{center} +% \href{https://tex.stackexchange.com/q/99765/33413}{% +% Document Class for Reference Cards (https://tex.stackexchange.com/q/99765/33413)}. +% \end{center} +% +% It contains contributions from: +% +% \begin{itemize} +% \item Mike Renfro % +% \href{https://tex.stackexchange.com/users/3345}{\faStackExchange https://tex.stackexchange.com/users/3345} +% \href{https://github.com/mikerenfro}{\faGithub https://github.com/mikerenfro} +% \item Sean Allred +% \href{https://tex.stackexchange.com/users/17423}{\faStackExchange https://tex.stackexchange.com/users/17423} +% \href{https://github.com/vermiculus}{\faGithub https://github.com/vermiculus} +% \item Eric Berquist +% \href{https://github.com/berquist}{\faGithub https://github.com/berquist} +% \end{itemize} +% +% Other code has also been imported into this repository. +% This is highlighted in the commented source code. +% +% See also \href{https://github.com/polyluxus/refcard/CONTRIBUTORS}{https://github.com/polyluxus/refcard/CONTRIBUTORS} +% +% \StopEventually{} +% +% \clearpage +% \interfootnotelinepenalty=10000 +% \section{Implementation} +% +% \subsection{Option definitions} +% +% These simple definitions for key-value pairs as class options are done with kvoptions as +% described in TUGBoat.\footnote{J. Wright, C. Feuersänger, TUGBoat, Vol. 30 (2009), No. 1, p. 110-122.} +% Using the prefix \lstinline`rcopt@` as an inbetween to distinguish values set from class options +% in the document. +% +% \begin{macrocode} +\RequirePackage{kvoptions} +\SetupKeyvalOptions{ + family=refcard, + prefix=rcopt@ +} +% \end{macrocode} +% +% Defining how many columns shall be used. The initial value is to use three, +% This can and should be set as \lstinline`columns=`\marg{int} in the preamble. +% This option is disabled for the body of the document. +% +% \begin{macrocode} +\DeclareStringOption[3]{columns} +\AtBeginDocument{% + \DisableKeyvalOption[action=error,package=refcard]{refcard}{columns}} +% \end{macrocode} +% +% Allow an option to set the standard margin via \lstinline`geometry`. +% +% \begin{macrocode} +\DeclareStringOption[1cm]{margin} +% \end{macrocode} +% +% Before inheriting the standard class \lstinline`article`, some options should +% be disabled to avoid potential clashes. +% Using these will result in warnings, or even errors. +% +% \begin{macrocode} +\DeclareVoidOption{portrait}{% + \PackageWarning{refcard}{Incompatible with portrait mode, setting will be ignored.}} +\DeclareVoidOption{twocolumn}{% + \PackageError{refcard}{Using 'multicol' for columns, use columns=2 instead.}} +\DeclareVoidOption{titlepage}{% + \PackageWarning{refcard}{Incompatible with a title page, setting will be ignored.}} +% \end{macrocode} +% +% Pass all other options to the \lstinline`article` class and then process all options. +% Finally load the most current version of the standard class to inherit. +% +% \begin{macrocode} +\DeclareDefaultOption{% + \PassOptionsToClass{\CurrentOptionKey}{article}} + +\ProcessKeyvalOptions{refcard} + +\LoadClass{article}[2014/09/29] +% \end{macrocode} +% +% \subsection{Additional Packages} +% +% Package \lstinline`etoolbox` provides additional hooks like \lstinline`\AtEndPreamble`. +% +% \begin{macrocode} +\RequirePackage{etoolbox} +% \end{macrocode} +% +% The page layout will be done with the package \lstinline`geometry`. +% First define a new length, which will be set to the key-value pair set via the class options. +% Then load the package with landscape mode and setting the margin. +% +% \begin{macrocode} +\RequirePackage{geometry}[2018/04/16] +\newlength\refcard@margin +\setlength\refcard@margin\rcopt@margin +\AtEndPreamble{% + \geometry{landscape,margin=\refcard@margin}} +% \end{macrocode} +% +% The page will be split in columns, therefore load \lstinline`multicol`. +% The begin and end document hooks will be ammended to automatically load a multicolumn environment. +% The number of columns is set via the \lstinline`columns=`\marg{number} key in the class options. +% +% \begin{macrocode} +\RequirePackage{multicol}[2018/04/20] +\AfterEndPreamble{% + \begin{multicols}{\rcopt@columns}} +\AtEndDocument{% + \end{multicols}} +% \end{macrocode} +% +% \subsection{Redifinition of the title} +% \begin{macro}{\maketitle} +% +% The title should be set quite dense and centered. +% +% \begin{macrocode} +\renewcommand{\maketitle}{% + {% + \begin{center}% + \Large \@title \\% + \vspace{0.1ex}% + \small \@author, \@date% + \end{center}% + }% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Redefine document divisions} +% +% The \lstinline`titlesec` package is used for manipulating the spacing +% around sections and subsections. +% +% \begin{macrocode} +\RequirePackage{titlesec} +\titlespacing{\section}{0.05ex}{0.05ex}{0.05ex} +\titlespacing{\subsection}{0.05ex}{0.05ex}{0.05ex} +% \end{macrocode} +% +% The \lstinline`parskip` package is used to set indentation and paragraph separation spacing. +% +% \begin{macrocode} +\RequirePackage[indent=0pt,skip=0.05ex]{parskip} +% \end{macrocode} +% +% Since a reference card usually only consits of one or two pages, +% page numbers are unnecessary. This loads the package \lstinline`nopageno` to supress them. +% This package redefines the definition of the pagestyle plain. +% +% \begin{macrocode} +\RequirePackage{nopageno} +% \end{macrocode} +% +% Section numbering is also superfluous for these document types, so it can be turned off. +% +% \begin{macrocode} +\setcounter{secnumdepth}{0} +% \end{macrocode} +% +% \subsection{Redefinition and new environments} +% +% Load the package \lstinline`enumitem` for more control and extensions of itemise, +% enumeration, and description environments. This class supports inline lists, +% so it seeds to be loaded with the appropriate option. +% +% \begin{macrocode} +\RequirePackage[inline]{enumitem}[2019/06/20] +% \end{macrocode} +% +% To generate denser lists, reduce spacing for items and above the environments globally. +% Redefine the \lstinline`itemize` environment do use dashes, and to calculate the left margin automatically. +% \begin{macrocode} +\setlist{noitemsep,topsep=0.05ex} +\setlist[itemize]{label=\textendash,leftmargin=*} +% \end{macrocode} +% +% The package \lstinline`environ` provides a more convinient interface for environment definitions. +% +% \begin{macrocode} +\RequirePackage{environ} +% \end{macrocode} +% +% For more convenient customisation of the environments, provide a key-value interface for the environments. +% These will control the font of the label, the number of columns used in the environments, +% and the alignment of some of the table columns.\footnote{% +% Part of the following code is adapted from the answer of Werner +% (\href{https://tex.stackexchange.com/users/5764/werner}{\faStackExchange https://tex.stackexchange.com/users/5764}) +% on \href{https://tex.stackexchange.com/a/34314/33413}{How to create a command with key values? % +% (https://tex.stackexchange.com/a/34314/33413)} +% Note that the package \lstinline`keyval` gets automatically loaded by \lstinline`kvoptions`.} +% +% \begin{macrocode} +\define@key{rclist}{labelfont}{\def\refcard@labelfont{#1}} +\define@key{rclist}{envcolumns}{\def\refcard@envcolumns{#1}} +\define@key{rclist}{cellalign}{\def\refcard@cellalign{#1}} +% \end{macrocode} +% +% Set some standard values to the above defined keys. +% The label should be set in bold, to match the standard of decription environments. +% Tables and column lists start with only two columns, the default alignment of the table columns is set to left. +% +% \begin{macrocode} +\setkeys{rclist}{% + labelfont=\bfseries,% + envcolumns=2,% + cellalign=l}% +% \end{macrocode} +% +% \subsubsection{Description like environments} +% \begin{environment}{refcardlist} +% +% The most basic environment is of description type. +% The label of widest argument will be used throughout the entire list. +% This is determined automatically.\footnote{% +% The automatically adjusting label width is based on the answers by user121799 (\faStackExchange no profile page) +% and Gonzalo Medina (\href{https://tex.stackexchange.com/users/3954/}{% +% \faStackExchange https://tex.stackexchange.com/users/3954}). +% \href{https://tex.stackexchange.com/q/461056/33413}{% +% Why conflict between mathtools and Gonzalo's solution for auto-adjusting description environment?% +% (https://tex.stackexchange.com/q/461056/33413)} +% \href{https://tex.stackexchange.com/q/130097/33413}{% +% Automatically set description list \lstinline`labelwidth` based on widest label?% +% (https://tex.stackexchange.com/q/130097/33413)}} +% +% First, define a length/ variable to hold the currently widest label. +% \begin{macrocode} +\newlength\refcardlist@widestitem +% \end{macrocode} +% +% The content of the environment is grouped to only affect the current definition. +% Apply the keys to the current environment. +% +% \begin{macrocode} +\NewEnviron{refcardlist}[1][]{% + \begingroup% + \setkeys{rclist}{#1}% +% \end{macrocode} +% +% The \lstinline`vbox` is necessary to avoid missing item warnings. +% +% \begin{macrocode} + \vbox{% + \global\refcardlist@widestitem=0pt% + \def\item[##1]{% + \settowidth\@tempdima{{\refcard@labelfont##1}}% + \ifdim\@tempdima>\refcardlist@widestitem\relax + \global\refcardlist@widestitem=\@tempdima\fi% + }% +% \end{macrocode} +% +% The \lstinline`\BODY` is set in a box that is never used. It is only parsed to determine the widest item. +% +% \begin{macrocode} + \setbox0=\hbox{\BODY}% + } +% \end{macrocode} +% +% The actual definition of the environment. The font has to be reset as mentioned in the \lstinline`enumitem` package manual. +% +% \begin{macrocode} + \begin{description}[% + font=\normalfont\refcard@labelfont,% + labelindent=0pt,% + labelwidth=\refcardlist@widestitem]% + \BODY + \end{description}% + \endgroup% +} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{refcardinline} +% +% The inline environment is used in unboxed mode to avoid awful spacing.\footnote{% +% See \href{https://tex.stackexchange.com/q/450569/33413}{How can I fix the spacing in enumitem inline lists?}} +% Items are joined with a semicolon, the label shall not devided from the following content, the list is +% terminated by a full stop. +% +% \begin{macrocode} +% +\NewEnviron{refcardinline}[1][]{% + \begingroup% + \setkeys{rclist}{#1} + \begin{description*}[% + mode=unboxed,% + font=\normalfont\refcard@labelfont,% + itemjoin={{; }},% + afterlabel={{\nobreakspace}},% + after={{.}}]% + \BODY + \end{description*}% + \endgroup% +} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{refcardcolumnlist} +% +% A list type environment that can be set in multiple columns. +% This is controlled via the key-values in the optional argument. +% The \lstinline`itemize` environment is redefined to start a new line after each item, +% the label should also not be separated from its content. +% The number of columns is controlled with the \lstinline`multicol` package, +% which is inthis case nested inside the main documents use. +% +% \begin{macrocode} +\NewEnviron{refcardcolumnlist}[1][]{% + \begingroup% + \setkeys{rclist}{#1} + \begin{multicols*}{\refcard@envcolumns} + \begin{itemize*}[% + itemjoin={{\newline}},% + afterlabel={{\nobreakspace}}] + \BODY + \end{itemize*}% + \end{multicols*} + \endgroup% +} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{refcardverblist} +% +% The environments created with the \lstinline`environ` package behave more like commands, +% than actual environments. Therefore they cannot handle verbatim input. +% Since this type of environment will probably be necessary, it needs to be defined differently, +% i.e. the standard way. The actual definition matches the above environment. +% +% \begin{macrocode} +\newenvironment{refcardverblist}[1][] +{ + \begingroup + \setkeys{rclist}{#1} + \begin{multicols*}{\refcard@envcolumns} + \begin{itemize*}[% + itemjoin={{\newline}},% + afterlabel={{\nobreakspace}}] +}{ + \end{itemize*} + \end{multicols*} + \endgroup +} +% \end{macrocode} +% \end{environment} +% +% \subsubsection{Table environments} +% \begin{environment}{refcardtable} +% +% This environment provides an easier interface to create a full witdh table +% with one automagic column width. This is achieved by loading the \lstinline`tabularx` package. +% +% \begin{macrocode} +\RequirePackage{tabularx} +% \end{macrocode} +% +% Define a new counter for the number of columns to be used. +% It has to be a counter, because it is used to do arithmetic evaluations. +% +% \begin{macrocode} +\newcounter{refcard@tablecolumns@count} +% \end{macrocode} +% +% The \lstinline`array` package, which is loaded by \lstinline`tabularx`, does not expand commands +% in the column definition. Tthis leads to an error where it does not recognise the token for the +% column alignment. With a bit of trickery, it is still possible\footnote{% +% This is based on the code provided by Bruno Le Floch +% (\href{https://tex.stackexchange.com/users/2707}{% +% \faStackExchange https://tex.stackexchange.com/users/2707}) +% on the answer for \href{https://tex.stackexchange.com/a/14460/33413}{% +% How do I expand a macro into a tabular head? (https://tex.stackexchange.com/a/14460/33413)}} +% First define a new columntype, which will then be recognised, but actually will be used to expand +% the supplied input. This is achieved by redefining \lstinline`\NC@rewrite@\expand` to use +% \lstinline`\expandafter` to expand the next token. +% +% \begin{macrocode} +\newcolumntype{\refcard@expandcoltype}{} +\long\@namedef{% + NC@rewrite@\string\refcard@expandcoltype}{% + \expandafter\NC@find} +% \end{macrocode} +% +% Next the table is set up. The last column is used to balance the table, therefore it is +% fixed to be \lstinline`X`. This is also the reason why the number of columns is reduced by one. +% +% \begin{macrocode} +\NewEnviron{refcardtable}[1][]{% + \begingroup% + \setkeys{rclist}{#1} + \setcounter{refcard@tablecolumns@count}{\refcard@envcolumns} + \addtocounter{refcard@tablecolumns@count}{-1} + \begin{tabularx}{\linewidth}{% + *{\value{refcard@tablecolumns@count}}{% + \refcard@expandcoltype\refcard@cellalign}% + X} + \BODY + \end{tabularx} + \endgroup% +} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{refcardtable} +% +% This environment provides an easier interface to create a full witdh table +% where the first column accepts math input. +% The last column is again used to balance the table and therefore is set to \lstinline`X` package. +% +% \begin{macrocode} +\NewEnviron{refcardmathtable}[1][]{% + \begingroup% + \setkeys{rclist}{#1} + \setcounter{refcard@tablecolumns@count}{\refcard@envcolumns} + \addtocounter{refcard@tablecolumns@count}{-2} + \begin{tabularx}{\linewidth}{% + >{\(\displaystyle}\refcard@expandcoltype\refcard@cellalign<{\)}% + *{\value{refcard@tablecolumns@count}}{% + \refcard@expandcoltype\refcard@cellalign}% + X } + \BODY + \end{tabularx} + \endgroup% + } +% \end{macrocode} +% \end{environment} +% +% That's it. +% +% \Finale +\endinput diff --git a/source/latex/refcard.ins b/source/latex/refcard.ins new file mode 100644 index 0000000..6a791a2 --- /dev/null +++ b/source/latex/refcard.ins @@ -0,0 +1,83 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% +%% This work is licensed under the %% +%% %% +%% Creative Commons Attribution-ShareAlike 4.0 International License %% +%% (CC BY-SA 4.0) %% +%% %% +%% To view a copy of this license, visit %% +%% %% +%% https://creativecommons.org/licenses/by-sa/4.0/ %% +%% %% +%% Repository: %% +%% %% +%% https://github.com/polyluxus/refcard %% +%% %% +%% Current Maintainer: %% +%% %% +%% Martin C Schwarzer %% +%% %% +%% For a list of contributers see the manual, or %% +%% %% +%% https://github.com/polyluxus/refcard/CONTRIBUTORS %% +%% %% +%% %% +%% %% +%% This work consists of the files refcard.dtx and refcard.ins %% +%% and the derived filebase refcard.cls. %% +%% %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\input docstrip.tex +\keepsilent + +\usedir{tex/latex/refcard} + +\preamble + +This is a generated file. + +This work is licensed under the + + Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0) + +To view a copy of this license, visit + + https://creativecommons.org/licenses/by-sa/4.0/ + +Repository: + + https://github.com/polyluxus/refcard + +Current Maintainer: + + Martin C Schwarzer + +For a list of contributers see the manual, or + + https://github.com/polyluxus/refcard/CONTRIBUTORS + +This work consists of the files refcard.dtx and refcard.ins +and the derived filebase refcard.cls. + +\endpreamble + +\generate{\file{refcard.cls}{\from{refcard.dtx}{class}}} + +\obeyspaces +\Msg{*************************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the following *} +\Msg{* file into a directory searched by TeX: *} +\Msg{* *} +\Msg{* refcard.cls *} +\Msg{* *} +\Msg{* To produce the documentation run the file cskeleton.dtx *} +\Msg{* through LaTeX. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{*************************************************************} + +\endbatchfile diff --git a/tex/latex/refcard.cls b/tex/latex/refcard.cls new file mode 100644 index 0000000..d73f2a5 --- /dev/null +++ b/tex/latex/refcard.cls @@ -0,0 +1,189 @@ +%% +%% This is file `refcard.cls', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% refcard.dtx (with options: `class') +%% +%% This is a generated file. +%% +%% This work is licensed under the +%% +%% Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0) +%% +%% To view a copy of this license, visit +%% +%% https://creativecommons.org/licenses/by-sa/4.0/ +%% +%% Repository: +%% +%% https://github.com/polyluxus/refcard +%% +%% Current Maintainer: +%% +%% Martin C Schwarzer +%% +%% For a list of contributers see the manual, or +%% +%% https://github.com/polyluxus/refcard/CONTRIBUTORS +%% +%% This work consists of the files refcard.dtx and refcard.ins +%% and the derived filebase refcard.cls. +%% +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesClass{refcard} + [2020/01/20 v1.0 Reference Card Class] +\RequirePackage{kvoptions} +\SetupKeyvalOptions{ + family=refcard, + prefix=rcopt@ +} +\DeclareStringOption[3]{columns} +\AtBeginDocument{% + \DisableKeyvalOption[action=error,package=refcard]{refcard}{columns}} +\DeclareStringOption[1cm]{margin} +\DeclareVoidOption{portrait}{% + \PackageWarning{refcard}{Incompatible with portrait mode, setting will be ignored.}} +\DeclareVoidOption{twocolumn}{% + \PackageError{refcard}{Using 'multicol' for columns, use columns=2 instead.}} +\DeclareVoidOption{titlepage}{% + \PackageWarning{refcard}{Incompatible with a title page, setting will be ignored.}} +\DeclareDefaultOption{% + \PassOptionsToClass{\CurrentOptionKey}{article}} + +\ProcessKeyvalOptions{refcard} + +\LoadClass{article}[2014/09/29] +\RequirePackage{etoolbox} +\RequirePackage{geometry}[2018/04/16] +\newlength\refcard@margin +\setlength\refcard@margin\rcopt@margin +\AtEndPreamble{% + \geometry{landscape,margin=\refcard@margin}} +\RequirePackage{multicol}[2018/04/20] +\AfterEndPreamble{% + \begin{multicols}{\rcopt@columns}} +\AtEndDocument{% + \end{multicols}} +\renewcommand{\maketitle}{% + {% + \begin{center}% + \Large \@title \\% + \vspace{0.1ex}% + \small \@author, \@date% + \end{center}% + }% +} +\RequirePackage{titlesec} +\titlespacing{\section}{0.05ex}{0.05ex}{0.05ex} +\titlespacing{\subsection}{0.05ex}{0.05ex}{0.05ex} +\RequirePackage[indent=0pt,skip=0.05ex]{parskip} +\RequirePackage{nopageno} +\setcounter{secnumdepth}{0} +\RequirePackage[inline]{enumitem}[2019/06/20] +\setlist{noitemsep,topsep=0.05ex} +\setlist[itemize]{label=\textendash,leftmargin=*} +\RequirePackage{environ} +\define@key{rclist}{labelfont}{\def\refcard@labelfont{#1}} +\define@key{rclist}{envcolumns}{\def\refcard@envcolumns{#1}} +\define@key{rclist}{cellalign}{\def\refcard@cellalign{#1}} +\setkeys{rclist}{% + labelfont=\bfseries,% + envcolumns=2,% + cellalign=l}% +\newlength\refcardlist@widestitem +\NewEnviron{refcardlist}[1][]{% + \begingroup% + \setkeys{rclist}{#1}% + \vbox{% + \global\refcardlist@widestitem=0pt% + \def\item[##1]{% + \settowidth\@tempdima{{\refcard@labelfont##1}}% + \ifdim\@tempdima>\refcardlist@widestitem\relax + \global\refcardlist@widestitem=\@tempdima\fi% + }% + \setbox0=\hbox{\BODY}% + } + \begin{description}[% + font=\normalfont\refcard@labelfont,% + labelindent=0pt,% + labelwidth=\refcardlist@widestitem]% + \BODY + \end{description}% + \endgroup% +} +\NewEnviron{refcardinline}[1][]{% + \begingroup% + \setkeys{rclist}{#1} + \begin{description*}[% + mode=unboxed,% + font=\normalfont\refcard@labelfont,% + itemjoin={{; }},% + afterlabel={{\nobreakspace}},% + after={{.}}]% + \BODY + \end{description*}% + \endgroup% +} +\NewEnviron{refcardcolumnlist}[1][]{% + \begingroup% + \setkeys{rclist}{#1} + \begin{multicols*}{\refcard@envcolumns} + \begin{itemize*}[% + itemjoin={{\newline}},% + afterlabel={{\nobreakspace}}] + \BODY + \end{itemize*}% + \end{multicols*} + \endgroup% +} +\newenvironment{refcardverblist}[1][] +{ + \begingroup + \setkeys{rclist}{#1} + \begin{multicols*}{\refcard@envcolumns} + \begin{itemize*}[% + itemjoin={{\newline}},% + afterlabel={{\nobreakspace}}] +}{ + \end{itemize*} + \end{multicols*} + \endgroup +} +\RequirePackage{tabularx} +\newcounter{refcard@tablecolumns@count} +\newcolumntype{\refcard@expandcoltype}{} +\long\@namedef{% + NC@rewrite@\string\refcard@expandcoltype}{% + \expandafter\NC@find} +\NewEnviron{refcardtable}[1][]{% + \begingroup% + \setkeys{rclist}{#1} + \setcounter{refcard@tablecolumns@count}{\refcard@envcolumns} + \addtocounter{refcard@tablecolumns@count}{-1} + \begin{tabularx}{\linewidth}{% + *{\value{refcard@tablecolumns@count}}{% + \refcard@expandcoltype\refcard@cellalign}% + X} + \BODY + \end{tabularx} + \endgroup% +} +\NewEnviron{refcardmathtable}[1][]{% + \begingroup% + \setkeys{rclist}{#1} + \setcounter{refcard@tablecolumns@count}{\refcard@envcolumns} + \addtocounter{refcard@tablecolumns@count}{-2} + \begin{tabularx}{\linewidth}{% + >{\(\displaystyle}\refcard@expandcoltype\refcard@cellalign<{\)}% + *{\value{refcard@tablecolumns@count}}{% + \refcard@expandcoltype\refcard@cellalign}% + X } + \BODY + \end{tabularx} + \endgroup% + } +\endinput +%% +%% End of file `refcard.cls'.