How do i add text to a variable which i defined earlier in the document? I tried it like this:
Code: Select all
\def\exos{some text}
\def\variable{\exos}
\def\exos{\variable added text}
Code: Select all
\def\exos{some text}
\def\variable{\exos}
\def\exos{\variable added text}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Code: Select all
\def\pretovar#1#2{\edef#1{\unexpanded{#2}\unexpanded\expandafter{#1}}}
\def\addtovar#1#2{\edef#1{\unexpanded\expandafter{#1#2}}}
\tt
\def\variable{var}
\meaning\variable
\pretovar\variable{pre}
\meaning\variable
\addtovar\variable{post}
\meaning\variable
\bye
Code: Select all
\documentclass{article}
\usepackage{etoolbox}
\begin{document}
\ttfamily
\def\variable{var}
\meaning\variable
\preto\variable{pre}
\meaning\variable
\appto\variable{post}
\meaning\variable
\end{document}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis