Approach to creating graphics in book - TikZ, SVG, PDF, Inkscape?
Please note the symbol node
style which should have the right font setup for the special font. My positioning-plus
has been used for the keys west below
which can be replaced with original positioning
and TikZ keys: west below=<distance> of node
is the same as below=<distance> of node.south west, anchor=north west
.
Code
\documentclass[tikz,convert=false]{standalone}%
\usetikzlibrary{chains,positioning-plus}
\pgfkeys{%
/handlers/.tikz/.code=\pgfkeys{\pgfkeyscurrentpath/.code=\tikzset{#1}},%
/handlers/.append tikz/.code=\pgfkeys{\pgfkeyscurrentpath/.append code=\tikzset{#1}},%
/handlers/.prefix tikz/.code=\pgfkeys{\pgfkeyscurrentpath/.prefix code=\tikzset{#1}}}
\newcommand*{\letterset}{\pgfqkeys{/letter}}
\letterset{
@int/start chain/.style={start chain=ch#1 going right},
columns/.initial=8,
rows/.initial={0,0,0,0,0,0,0},
column width/.initial=+.5cm,
row height/.initial=+.6cm,
%
every letter picture/.tikz={
node distance=+0pt,
every node/.append style={
minimum width=\pgfkeysvalueof{/letter/column width},
minimum height=\pgfkeysvalueof{/letter/row height},
text depth=+0pt,
outer sep=+0pt,
}},
every header label/.tikz={font=\tiny,rotate=90,inner sep=+0pt,outer sep=+0pt},
every cell node/.tikz={draw=gray, ultra thin},
every 1 node/.tikz={fill=black},
every 0 node/.tikz={},
data column node/.tikz={
align=right,
text width=\widthof{000}
},
symbol node/.tikz={
font=\ttfamily}% Here should stand the command for the XeTeX font
}
\makeatletter
\newcommand{\letterChart}[4][]{%
\begingroup
\pgfqkeys{/letter}{#1}%
\pgfkeysgetvalue{/letter/columns}\letter@Columns
\pgfmathsetbasenumberlength{\letter@Columns}%
\pgfkeysgetvalue{/letter/rows}\letter@Rows
\tikzpicture[/letter/every letter picture/.try, /letter/@int/start chain/.list/.expanded={0,1,...,\letter@Columns}]
\node[anchor=west,/letter/head node/.try] (letter@head) {Bit Values of Pixels};
\foreach \letter@Power in {1,...,\letter@Columns} {
\ifnum\letter@Power=1\tikzset{/letter/@int/first node/.tikz={west below=of letter@head}}\fi
\node[on chain=ch0,/letter/@int/first node/.try,/letter/header node/.try,label={[/letter/every header label/.try]center:\pgfmathprint{int(2^(\letter@Columns-\letter@Power))}}] {};
}
\foreach \letter@Row[count=\c@prevRow from 0, count=\c@Row] in \letter@Rows {%
\pgfmathbin{\letter@Row}
\edef\letter@Digits{\expandafter\letter@IncludeComma\pgfmathresult\stop@Letter}
\foreach \letter@Digit[count=\c@Col] in \letter@Digits{
\ifnum\c@Col=1\tikzset{/letter/@int/first node/.tikz={below=of ch\c@prevRow-begin}}\fi
\node[on chain=ch\c@Row,/letter/@int/first node/.try,/letter/every cell node/.try, /letter/every \letter@Digit\space node/.try] {};
}
\node[/letter/data column node/.try, right=\pgfkeysvalueof{/letter/column width} of ch\c@Row-end] (letter@datacolumn) {\letter@Row};
}
\node[anchor=base east, /letter/head node/.try] at ([email protected]|[email protected]) {Data};
\node[below=\pgfkeysvalueof{/letter/row height} of letter@datacolumn, /letter/data column node/.try] (letter@ascii) {#3};
\node[mid left=of letter@ascii] {ASCII Code:};
\node[below=of letter@ascii, /letter/data column node/.try] (letter@screen) {#4};
\node[mid left=of letter@screen] {Screen Code:};
\node[anchor=base west, /letter/symbol node/.try] at ([email protected]|[email protected] west) {#2};
\endtikzpicture
\endgroup
}
\def\letter@IncludeComma#1#2{%
#1%
\ifx\stop@Letter#2
\expandafter\pgfutil@gobble
\else
\expandafter\pgfutil@firstofone
\fi
{,\letter@IncludeComma#2}}
\makeatother
\begin{document}
\letterChart[rows={60,102,110,110,96,98,60,0}]{@}{64}{0}
\letterChart[rows={24,60,102,102,126,102,102,0}]{A}{65}{1}
\letterChart[rows={124,102,102,124,102,102,124,0}]{B}{66}{2}
\letterset{
every letter picture/.append tikz={node distance=+3pt},
/tikz/nodes={minimum width=\pgfkeysvalueof{/letter/column width}-3pt,
minimum height=\pgfkeysvalueof{/letter/row height}-3pt},
every cell node/.append tikz={shape=circle,draw=none},
column width/.initial=+.5cm,
row height/.initial=+.5cm}
\letterChart[rows={60,102,110,110,96,98,60,0}]{@}{64}{0}
\letterChart[rows={24,60,102,102,126,102,102,0}]{A}{65}{1}
\letterChart[rows={124,102,102,124,102,102,124,0}]{B}{66}{2}
\end{document}
Output
As suggested by Ethan Bolker, I would export them directly from Excel as a pdf
. Place all the pdf
files in a single folder. Then you can use the following loop to crop all the pdfs
:
for img in *.pdf
do
convert -quality 100 -crop 300x100+20+50 "$img" "new_$img"
echo $img
done
where: 300
is the width, 100
is the height, 20
is the cropped portion on x axis, 50
is the cropped portion on y axis.
--> (20,50)
is the top left corner of your image.
If you have problems with the scale, you can add -scale 100%
to the command.
Note: for this loop to be useful, all the characters you are going to export must be the same size.
An attempt only with LaTeX from the scratch:
\documentclass{article}
\usepackage{colortbl,xcolor}
\usepackage{booktabs}
\usepackage{array}
\usepackage{rotating,hhline}
\providecommand{\X}{\cellcolor{red!50}}
\providecommand{\CR}{\hhline{--------~-}}
%\renewcommand\arraystretch{1}
\begin{document}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c}
\multicolumn{9}{l}{Bit values of Pixels} &
\multicolumn{1}{c}{Data}\\
\multicolumn{1}{c}{}\\
\multicolumn{1}{c}{\begin{sideways}\small 128\end{sideways}} &
\multicolumn{1}{c}{\begin{sideways}\small 64\end{sideways}} &
\multicolumn{1}{c}{\begin{sideways}\small 32\end{sideways}} &
\multicolumn{1}{c}{\begin{sideways}\small 16\end{sideways}} &
\multicolumn{1}{c}{\begin{sideways}\small 8\end{sideways}} &
\multicolumn{1}{c}{\begin{sideways}\small 4\end{sideways}} &
\multicolumn{1}{c}{\begin{sideways}\small 2\end{sideways}} &
\multicolumn{1}{c}{\begin{sideways}\small 1\end{sideways}} &
\multicolumn{1}{c}{}\\
\CR & & & \X & \X & & & & & 24\\
\CR & & \X & \X & \X & \X & & & & 60\\
\CR & \X & \X & & & \X & \X & & & 102\\
\CR & \X & \X & & & \X & \X & & & 102\\
\CR & \X & \X & \X & \X & \X & \X & & & 126\\
\CR & \X & \X & & & \X & \X & & & 102\\
\CR & \X & \X & & & \X & \X & & & 102\\
\CR & & & & & & & & & 0\\
\CR
\end{tabular}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{>{\centering}p{1cm}}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{}\\
\cline{1-1} \cline{10-10}
A & \multicolumn{8}{r|}{ASCII Code:} & 64\\
\cline{1-1} \cline{10-10}
\multicolumn{1}{c}{} & \multicolumn{8}{r|}{Screen Code:} & \\
\cline{10-10}
\end{tabular}
\end{document}