Hi there,
AFAICS, the subfile package puts its sub-document in a group, and
\ADD
's result remains local---so yes, it's basically a scope issue.
You could globalize the result in your sub file, e.g.
Code: Select all
\documentclass[12pt, dutch]{report} % to allow chapter tags
\usepackage{subfiles} % for splitting the project into seperate files
\usepackage{calculator} % perform calculations within LaTeX
\usepackage{memory} % use global variables
\begin{filecontents}{chapter/logboek-februari.tex}
% -*- root: rootfile.tex -*-
\documentclass[../rootfile.tex]{subfiles}
%the timeInit variable should be 550+310 = 860
\ADD{\timeInit}{310}{\timeInit}%<-- it doesn't help to use a different variable name here, or where was `\timeInitiatie' defined?
\xdef\timeInit{\timeInit}%<-- makes the change to \timeInit global
timeInit (sub): \timeInit
\end{filecontents}
%first I enter a value in the main file:
%using the calulator package, I add the value 550 to the variable 'timeInit'
\COPY{550}{\timeInit}
\begin{document}%<-- missing
%now I link a subfile that manipulates the timeInit value:
\chapter{logboek - februari}
\label{cha:logboek-februari}
\subfile{chapter/logboek-februari.tex}
timeInit (main): \timeInit
\end{document}
or you could use
\input
instead of
\subfile
Code: Select all
\documentclass[12pt, dutch]{report} % to allow chapter tags
\usepackage{calculator} % perform calculations within LaTeX
\usepackage{memory} % use global variables
\begin{filecontents}{chapter/logboek-februari.tex}
% -*- root: rootfile.tex -*-
%the timeInit variable should be 550+310 = 860
\ADD{\timeInit}{310}{\timeInit}%<-- it doesn't help to use a different variable name here, or where was `\timeInitiatie' defined?
timeInit (sub): \timeInit
\end{filecontents}
%first I enter a value in the main file:
%using the calulator package, I add the value 550 to the variable 'timeInit'
\COPY{550}{\timeInit}
\begin{document}%<-- missing
%now I link a subfile that manipulates the timeInit value:
\chapter{logboek - februari}
\label{cha:logboek-februari}
\input{chapter/logboek-februari.tex}
timeInit (main): \timeInit
\end{document}
(you may need to delete `chapter/logboek-februari.tex' and/or you may need to create a sub-folder `chapter' before compiling this code)
KR
Rainer