Tag Info

New answers tagged

3

My package tcolorbox provides another possible answer for the question. It allows to place the source code before or after the output. With version 2.20, source and output can be set side-by-side. The output can be placed inside a colored box or outside, before the source or after the source. \documentclass{article} \usepackage[skins,listings]{tcolorbox} ...


3

By rereading the documentation of kvoptions once more, I figured it out myself. This is the result: \RequirePackage{expl3,kvoptions,siunitx} \SetupKeyvalOptions{family=threshold,prefix=threshold@} \DeclareStringOption[1]{low}[0.01] \DeclareStringOption[1]{high}[100] \ProcessKeyvalOptions* \sisetup{scientific-notation=true} \ExplSyntaxOn \cs_new_eq:NN ...


6

rather than through a .cls you should do this using a .sty file (a ›package‹). mystyle.sty would look something like this: \ProvidesPackage{mystyle} \newcommand*{\myname}{Derpina Derpson} \newcommand*{\mymail}{myemail@campus.edu} \endinput and in your documents, you simply load that package and have access to the things defined there: ...


5

You don't need to create a separate class, just a package or even a regular input file. You could create a file, say myconfig.tex, that contains definitions such as \newcommand{\myemail}{myemail@campus.edu} and in your documents use \input{myconfig} and then refer to \myemail instead of myemail@campus.edu. Whenever you need to change your personal ...


4

I recently wrote some code to take a TeX source, find repeated patterns, and replace them by macros. This could be used as a step to make the source code less readable. It could also be modified to turn macro names into an unreadable mess, so that \show and \tracingall cannnot give insight into what is happening. Unfortunately, if you use packages, you ...


5

The following is less impressive than the other answers from the visual point of view (Mark, I like yours!), but addresses the actual question of the OP: Bit-wise iteration over hexadecimal values, which becomes fairly easy when using the bitset package by Heiko Oberdiek: \documentclass{article} \usepackage{bitset} \usepackage{pgf,pgffor} \begin{document} ...


5

Not sure this is robust, it only works within the limited numerical range of PGFMath, and clearly I've gone for something a bit more over-the-top than the requirements. EDIT: following Daniels example of the bitset package the code has been updated to be a bit more like that. \documentclass[border=5pt]{standalone} \usepackage{tikz} \newcount\bitcount ...


9

You can use snapshot and bundledoc to bundle all necessary files to compile your document.


1

Why not just send them the package with all of the other .tex files and images that you will send them? Or, use a site like writelatex.com, where you can share all of your files online with collaborators?


10

Files can be tested via \IfFileExists{file}{yes}{no}. The following snipset uses a switch \if@mysty@lineno that remembers the option setting lineno for package mysty. Package lineno and \linenumbers are only executed, if the option lineno was given. This way, the package lineno is not loaded unnecessarily if it is not needed. Packages cannot be loaded ...


7

Here's what you can put in mysty.sty: \newif\ifmysty@lineno \DeclareOption{lineno}{\mysty@linenotrue} [...] \ProcessOptions\relax [...] \ifmysty@lineno \IfFileExists{lineno.sty} {\RequirePackage{lineno}} {\PackageWarningNoLine{mysty}{You requested `lineno.sty' which\MessageBreak doesn't exist on your system}} \fi Then if you call ...


4

I didn't get exactly what you want to do but pgfmath already understands Hex syntax. \documentclass{article} \usepackage{tikz} \begin{document} \pgfmathparse{bin(0x1F)} \pgfmathresult \pgfmathparse{bin(0X1F)} \pgfmathresult \end{document} Both leads to 11111


4

You can use LaTeX3 that has a function for converting integers to binary. Instead of \fbox use your preferred macro. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\dispbyte}{m} { \compiler_dispbyte:n { #1 } } \tl_new:N \l_compiler_bits_tl \tl_new:N \l_compiler_byte_tl \cs_new_protected:Npn \compiler_dispbyte:n #1 { % ...


4

This loops over the binary digits from the hex, for testing it just prints them out (in reverse order to keep the code simple) \documentclass{article} \makeatletter \def\dispbyte#1{\@displaybyte#1\relax} \def\@displaybyte#1x#2\relax{\count@\string"#2\relax \loop \fbox{\ifodd\count@ 1\else0\fi}% \divide\count@\tw@ \ifnum\count@>\z@ \repeat} ...


2

I recently had to write a new class without very much LaTeX experience at all. I found LaTeX2e for class and package writers (http://www.ctan.org/pkg/clsguide) a great way to get started. It includes several examples. It sounds like you already know what you're doing, so apologies if this is obvious, but a good way to start is to load a standard LaTeX class ...



Top 50 recent answers are included