I'm trying to make a table, and I would like to (re)define a command in this table. But for some reason LaTeX forgets that I redefined the command when I move to the next cell. Is there some other way to redefine it, so that this does not happen?
And something else: actually I only need to store a string. Is there some way to store a string other than use commands? Something like a \newstring command in the same way as the \newlength command for lengths?
Thank you!
Minimal working example (okay, maybe not totally minimal, the same happens for tabulars instead of longtables)
Code: Select all
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{longtable}
\newcommand{\var}{abc}
\begin{document}
\begin{longtable}{c|c}
\var & \renewcommand{\var}{def} \var \\ \hline
\var & \var \\ \hline
\renewcommand{\var}{ghi} \var & \var \\ \hline
\var \renewcommand{\var}{jkl} & \var \\
\end{longtable}
\end{document}
abc def
abc abc
ghi abc
abc abc
Wanted output:
abc def
def def
ghi ghi
ghi jkl