latex-grid-system
latex-grid-system copied to clipboard
grid-system + \newenvironment + \lrbox => no way
trafficstars
I've struggled to make a pair of environments that would extend Row and Cell environments,
but also employing \lrbox (aka LaTeX's \savebox) for the Cell contents.
I have tried multiple approaches, but failed, as illustrated:
%% -*- tex-compile-commands: (("latexmk -pdflatex='xelatex' -pdf %f && evince %r.pdf" "%f" "%r.pdf")) -*-
%% \documentclass{beamer}
\documentclass[12pt]{article}
\usepackage{grid-system}
\newsavebox{\xbox}
%%% Savebox: expected result
\newenvironment{context.sb}
{}
% ...
{}
\newenvironment{entry.sb}
{\begin{lrbox}{\xbox}}
% ...
{\end{lrbox}%
\usebox{\xbox}}
%%% Grid system, try 1: usage commented out, doesn't compile:
%%% LaTeX Error: \begin{Cell} on input line 97 ended by \end{entry.gs1}.
%%% l.99 \end {entry.gs1}
\newenvironment{context.gs1}
{\begin{Row}}
% ...
{\end{Row}}
\newenvironment{entry.gs1}
{\begin{Cell}{1}}
% ...
{\end{Cell}}
%%% Grid system, try 2: OK, expected result
\newenvironment{context.gs2}
{\Row}
% ...
{\endRow}
\newenvironment{entry.gs2}
{\Cell{1}}
% ...
{\endCell}
%%% Savebox + Grid system, try 1: cell contents missing!
\newenvironment{context.sb.gs1}
{\begin{Row}}
% ...
{\end{Row}}
\newenvironment{entry.sb.gs1}
{\begin{lrbox}{\xbox}}
% ...
{\end{lrbox}%
\begin{Cell}{1}%
\usebox{\xbox}%
\end{Cell}}
%%% Savebox + Grid system, try 2: usage commented out, doesn't compile:
%%% LaTeX Error: \begin{entry.sb.gs2} on input line 135 ended by \end{context.sb.gs2}.
%%% l.141 \end {context.sb.gs2}
\newenvironment{context.sb.gs2}
{\Row}
% ...
{\endRow}
\newenvironment{entry.sb.gs2}
{\begin{lrbox}{\xbox}}
% ...
{\end{lrbox}%
\Cell{1}%
\usebox{\xbox}%
\endCell}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\hrule
\begin {context.sb}
context.sb
\begin {entry.sb}
entry.sb one
\end {entry.sb}%
\begin {entry.sb}
entry.sb two
\end {entry.sb}%
\end {context.sb}%
%%% Usage commented out, doesn't compile:
%%% LaTeX Error: \begin{Cell} on input line 97 ended by \end{entry.gs1}.
%%% l.99 \end {entry.gs1}
%% \hrule
%% \begin {context.gs1}
%% context.gs1
%% \begin {entry.gs1}
%% entry.gs1 one
%% \end {entry.gs1}%
%% \begin {entry.gs1}
%% entry.gs1 two
%% \end {entry.gs1}%
%% \end {context.gs1}%
\hrule
\begin {context.gs2}
context.gs2
\begin {entry.gs2}
entry.gs2 one
\end {entry.gs2}%
\begin {entry.gs2}
entry.gs2 two
\end {entry.gs2}%
\end {context.gs2}%
\hrule
\begin {context.sb.gs1}
context.sb.gs
\begin {entry.sb.gs1}
entry.sb.gs one
\end {entry.sb.gs1}%
\begin {entry.sb.gs1}
entry.sb.gs two
\end {entry.sb.gs1}%
\end {context.sb.gs1}%
%%% Usage commented out, doesn't compile:
%%% LaTeX Error: \begin{entry.sb.gs2} on input line 135 ended by \end{context.sb.gs2}.
%%% l.141 \end {context.sb.gs2}
%% \hrule
%% \begin {context.sb.gs2}
%% context.sb.gs
%% \begin {entry.sb.gs2}
%% entry.sb.gs one
%% \end {entry.sb.gs2}%
%% \begin {entry.sb.gs2}
%% entry.sb.gs two
%% \end {entry.sb.gs2}%
%% \end {context.sb.gs2}%
\end{document}
The output:

@bitzl, note how the obvious approach to define an extended environment fails in "Grid system, try 1".
This is:
xelatex --version
XeTeX 3.14159265-2.6-0.99992 (Web2C 2015/NixOS.org)
kpathsea version 6.2.1
Copyright 2015 SIL International, Jonathan Kew and Khaled Hosny.
There is NO warranty. Redistribution of this software is
covered by the terms of both the XeTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the XeTeX source.
Primary author of XeTeX: Jonathan Kew.
Compiled with ICU version 56.1; using 56.1
Compiled with zlib version 1.2.8; using 1.2.8
Compiled with FreeType2 version 2.6.2; using 2.6.2
Compiled with Graphite2 version 1.3.6; using 1.3.6
Compiled with HarfBuzz version 1.1.2; using 1.1.2
Compiled with libpng version 1.6.20; using 1.6.20
Compiled with poppler version 0.43.0
Compiled with fontconfig version 2.11.1; using 2.11.1