<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% !TeX root=demo.tex
\ProvidesPackage{grid-system}[2014/02/16 v. 0.3.0 LaTeX Grid System]

\RequirePackage{calc}
\RequirePackage{xkeyval}
\RequirePackage{ifthen}
\RequirePackage{environ,forloop}

\newcommand{\gridsystem@cellwidth}[2]{#1\linewidth/#2}

\newlength{\gridsystem@cellsep}
\setlength{\gridsystem@cellsep}{1.75em}

\newlength{\gridsystem@one@cellwidth}

\newcounter{gridsystem@cellinrow}

% Macros to finish cells and rows, so that the areas between cells and rows can be defined very flexibly.
\newcommand{\gridsystem@finishrow}{\bigskip}
\newcommand{\gridsystem@finishcell}{\hskip\gridsystem@cellsep}
\newcommand{\gridsystem@finishlastcell}{}

\define@key{row}{cellsep}{\setlength\gridsystem@cellsep{#1}}

%\def\convertto#1#2{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1#1}

\newenvironment{row}[3][cellsep=1.75em]{%
\setkeys{row}{#1}%
\setcounter{gridsystem@cellinrow}{0}%
\noindent%
\newenvironment{cell}[1]{%
	\addtocounter{gridsystem@cellinrow}{##1}%
	\setlength{\gridsystem@one@cellwidth}{(\linewidth-\gridsystem@cellsep*(#3-1))/#2}%
	\begin{minipage}[t]{##1\gridsystem@one@cellwidth}%
}{%
	\end{minipage}%
	\@ignoretrue% Ignore spaces
	\ifthenelse{\value{gridsystem@cellinrow}&lt;#2}{%
		\gridsystem@finishcell%
	}{%
		\gridsystem@finishlastcell%
	}%
}%
}{
	\gridsystem@finishrow%
}

\NewEnviron{Cell}[1]{%
	%\global\@namedef{gridsystem@cellcontent\arabic{gridsystem@cellcount}}{\BODY}%
	%\edef\@celltemp{\BODY}%
	%\global\@namedef{gridsystem@cellcontent\arabic{gridsystem@cellcount}}{\@celltemp}%
	\expandafter\global\expandafter\let\csname gridsystem@cellcontent\arabic{gridsystem@cellcount}\endcsname\BODY%
	\global\@namedef{gridsystem@cellwidth\arabic{gridsystem@cellcount}}{#1}%
	\stepcounter{gridsystem@cellcount}%
	\addtocounter{gridsystem@stripecount}{#1}%
}

%%%%
%%%% equivalent of \@namedef for counters?
%%%%

\newcounter{gridsystem@cellcount}
\newcounter{gridsystem@stripecount}

\newenvironment{Row}[1][cellsep=1.75em]{%
\setkeys{row}{#1}%
\setcounter{gridsystem@cellinrow}{0}%
\setcounter{gridsystem@stripecount}{0}%
\noindent%
}{%
\setlength{\gridsystem@one@cellwidth}{(\linewidth-\gridsystem@cellsep*(\value{gridsystem@cellcount}-1))/\value{gridsystem@stripecount}}%
% For each 1..gridsystem@cellcount
\forloop{gridsystem@cellinrow}{0}{\value{gridsystem@cellinrow} &lt; \value{gridsystem@cellcount}}{%
\expandafter\begin{minipage}[t]{\dimexpr\@nameuse{gridsystem@cellwidth\arabic{gridsystem@cellinrow}}\gridsystem@one@cellwidth\relax}%
\@nameuse{gridsystem@cellcontent\arabic{gridsystem@cellinrow}}%
\end{minipage}%
\@ignoretrue% Ignore spaces
\ifthenelse{\value{gridsystem@cellinrow}&lt;\value{gridsystem@cellcount}}{%
	\gridsystem@finishcell%
}{%
	\gridsystem@finishlastcell%
}%
}%
\setcounter{gridsystem@cellcount}{0}%
\setcounter{gridsystem@stripecount}{0}%
%\gridsystem@finishrow%
}
</pre></body></html>