0

Assuming we have generated contents of card (i.e. excluding top header row and left indexing column) , for eg. with some pseudo-random generator script. How to render such to mimic the look of one from passwordcard.org ?

Is it possible to make it nice to put content into template (e.g. pure txt, or some csv capable environment or sth), so one can easily copy&paste contents without need of retyping into individual cells (or making script to do so)?

How to generate cards similar to passwordcard.org, for example this one: enter image description here

May be without border and code on bottom , like this:

enter image description here

With defined page size (fitting standard business card, 3.5 in × 2 in).

  • 1
    Do you just want to mimic the visual appearance (that would be quite easy with colortbl) or do you actually want to generate the (random?) strings? – Tobi May 04 '16 at 21:25
  • Thanks for quesiton! Such always helps me understand ambiguities in question. I'd like to assume that we have contents in some file generated earlier (however, including such script in any language, would be a great addition to answer :) ).

    Would be perfect if one could somehow "copy&paste" desired content into some section of doc (or maybe somehow include) without need or retyping (or using script to do so) into every individual cell.

    – Grzegorz Wierzowiecki May 04 '16 at 21:31
  • OK … thats easy … wait a few minutes till I have the code ready ;-) – Tobi May 04 '16 at 21:35
  • I didn't know how to start, which tool to use. colortbl sounds already like big tip! :) – Grzegorz Wierzowiecki May 04 '16 at 21:36
  • I added an answer, however adding a MWE with at least the {tabular} and the string would have been your job ;-) Goodnight! – Tobi May 04 '16 at 21:48

1 Answers1

3

Here you go …

I used colortbl (loaded by xcolor) to color the rows in the tabular and TikZ to draw the frame around it. Some more explanations are in the code comments, let me know if I should explain something in more detail.

enter image description here

\documentclass[fontsize=8.5pt]{scrartcl}

% set page size
\usepackage{geometry}
\geometry{
   paperwidth = 3.5in,
   paperheight = 2in,
   margin = 0.15in,
}

% load array for the '>{stuff}' syntax in tabular
\usepackage{array}

% load xcolor to define the colors
% 'table' option loads colortbl (reccomended way)
\usepackage[table]{xcolor}
% define the colors for the rows
\definecolor{row1}{HTML}{FFFFFF}
\definecolor{row2}{HTML}{C1C1C1}
\definecolor{row3}{HTML}{F0C4C1}
\definecolor{row4}{HTML}{D6FDC2}
\definecolor{row5}{HTML}{FFFFC3}
\definecolor{row6}{HTML}{C1C2FF}
\definecolor{row7}{HTML}{F0C5FF}
\definecolor{row8}{HTML}{D6FEFF}

% make rows a bit higher
\renewcommand{\arraystretch}{1.25}

% we want to use TikZ to add the border around the page
% to get it at the right position, compile twice!
\usepackage{tikz}
   \usetikzlibrary{calc}

\begin{document}
% content should be centered and in monotype font:
\centering\ttfamily
% 1. the border, relative to the 'current page' node
\begin{tikzpicture}[remember picture, overlay]
   \draw [rounded corners = 3mm, thick] ($(current page.north west)+(0.1in,-0.1in)$)
      rectangle ($(current page.south east)+(-0.1in,0.1in)$);
\end{tikzpicture}
% 2. the table containing the random codes
% - '>{\scriptsize}' manes add '\scriptsize' to every cell in this col
% - '\rowcolor{row1}' colors the row – who had guessed that ;-)
\begin{tabular}{>{\scriptsize}ll}
                  & Header row with same amount of characters \\
\rowcolor{row1} 1 & Some quite random charachters in this row \\
\rowcolor{row2} 2 & Some quite random+=!@\#\$\%\textasciicircum\&*()\_-\textbackslash|'"`\textasciitilde \\
\rowcolor{row3} 3 & \verb?Some quite random+=!@#$%^&*()_-\|'"`~? \\
\rowcolor{row4} 4 & Some quite random charachters in this row \\
\rowcolor{row5} 5 & Some quite random charachters in this row \\
\rowcolor{row6} 6 & Some quite random charachters in this row \\
\rowcolor{row7} 7 & Some quite random charachters in this row \\
\rowcolor{row8} 8 & Some quite random charachters in this row \\
\end{tabular}

% 3. the smaller code at the bottom
% - \vfill inserst a stretchabe space, so the code is shifted to the
%   bottom of the page
\vfill
\scriptsize
Smaller code
\end{document}

To find the symbols in the first row you may take a look at symbols-a4.pdf or How to look up a symbol or identify a math symbol or character?.

PS: I was too lazy to type the strings from your pictures ;-)

Tobi
  • 56,353
  • Could you please change first row to "Header Row" from "Some random ...". In password card,the first row with symbols is header row, that does not take part in password but can help you memorize navigation. Apart from this, I need to check if code works on my machines :) (Archlinux, Ubuntu Server, Raspibian ;) ) and then I will be ready to mark it as answer :). Thanks! – Grzegorz Wierzowiecki May 04 '16 at 22:14
  • Won't the ampersand characters, \ and \\ in the random string cause column / line breaks? – AJN May 05 '16 at 04:35
  • LaTeX Font Warning: Font shape 'OML/cmm/m/it' in size <8.5> not available (Font) size <8> substituted on input line 46. - don't you have such warnings? http://pastebin.com/d4KZfiyi – Grzegorz Wierzowiecki May 05 '16 at 07:21
  • @AJN here is how to put standard symbols in above template: \rowcolor{row1} 1 & Some quite random+=!@\#\$\%\textasciicircum\&\*()\_-\textbackslash|'"\\textasciitilde \ full working example inpasswordcard_template_with_standard_symbols.tex` file captured in gist – Grzegorz Wierzowiecki May 05 '16 at 07:42
  • @Tobi , confirmed! Works (despite mentined warnings)! Thanks a lot! – Grzegorz Wierzowiecki May 05 '16 at 07:45
  • 1
    @AJN: Sure if you don’t escape them, some symbols can cause trouble. You can either escape them as Grzegorz suggested or use \verb. I added both possibilities to may example. – Tobi May 05 '16 at 07:50
  • 1
    @GrzegorzWierzowiecki: The font size warning happens because the font is not available in a certain size and TeX falls beck to the next existing value. To get rid of it add \RequirePackage{fix-cm} before \documentclass. See http://tex.stackexchange.com/q/240992/4918 for example. – Tobi May 05 '16 at 08:02