I'm trying to create an environment within a twocolumn
document which behaves differently depending on which column it's in. Specifically, I'm making a tcolorbox
, which is supposed to stretch to the edge of the page, which may be either left or right depending on the column the box is placed in. However, for this question, the conditioning is of importance.
In order to do that I've tried using the \if@firstcolumn
command.
\documentclass[a4paper, 11pt, twocolumn, twoside]{book}
\usepackage{lipsum}
\usepackage{geometry}
\geometry{a4paper, includeheadfoot,top=0cm, bottom=0cm, headheight=2cm, headsep=0.1cm, footskip=2cm, left=1cm, right=1cm}
\newenvironment{columnbox}{\par\bfseries
\if@firstcolumn FIRST \else SECOND \fi
}{COLUMN\par}
\begin{document}
\pagestyle{empty}
\lipsum[1]
\begin{columnbox}
\end{columnbox}
\lipsum
\begin{columnbox}
\end{columnbox}
\lipsum
\begin{columnbox}
\end{columnbox}
\lipsum
\begin{columnbox}
\end{columnbox}
\end{document}
This, however, does not work; instead of giving out the correct value, it gives the \else
value no matter which column it's in.
I suspect I've misunderstood the way it gets evaluated and it gets checked (and fixed to false, since there's no column?) in the preamble already, instead of being checked any time the environment is called, as I'd hoped.
What would be the correct way to achieve what I'm trying to do?
multicol
, Detecting current column inmulticol