How to pass on variables across documents?

I am working on an extensive syllabus for a course, that consists of multiple separate documents (course guide, assignments, portfolio instructions). To make sure that making changes to the document is easier in the future, I want to be able to set variables (such as the year of the course, the dates of the deadlines, names of the teachers) at a central place, in such a way that if I make changes there, these get incorporated throughout all the other documents too.

Within one document, I can solve this by using ‘user variables’, but I cannot refer to these from within another document. How do I set variables that can be easily accessed across documents?

One extra constraint is that I should be able to send the files to other teachers and that the references must still work (as long as the files are in the same folder).

Any help is greatly appreciated!

The only solution I can see is to use a combination of master documents + “the” reference document but this needs to be explored because I have not experimented a lot with it (and there are small issues with updates to heading cross-references).

Of course, I assume you already work with a template to guarantee that all your documents look alike and you follow a strict discipline where you forbid yourself direct formatting, i.e. you apply systematically character styles to embolden or italicise words, none of your paragraphs are styled Default Paragraph Style and vertical spacing is integrated into paragraph styles instead of being done with empty paragraphs.

  • Create your “configuration” sub-document. You can define your “reference values” either as cross-references over text (but you must be careful when updating) or as variables.
    I recommend you add comments and explanations to these definitions to facilitate further maintenance. You can even stuff everything in a 3-column table: variable name (or cross-reference name), value, comment/description/explanation.
    Assign a specific paragraph style to this text with Hidden attribute so that it doesn’t print in the masters.
    Configure Writer so that hidden text is displayed on screen (it shows up with dotted underline and never prints anyway). This also requires to enable View>Formatting Marks.

  • Transform your present documents into master documents. The simplest way is to copy their contents into a fresh master.
    At the very beginning of it, insert the reference document with the Navigator in "Master View*: right-click on Text and Insert>File.
    All the definitions in the reference document are now available in the master.

1 Like

Thank you @ajlittoz ! This is an ingenious solution.

@ajlittoz , trying out your solution, I notice that some things are not clear to me.

You write that, “the simplest way is to copy their contents into a fresh master.” Do you mean that I should copy the text of all the files into one single, large file - or should I add the subdocuments through the Insert>File option?

If the first: what is the advantage of even using a master? If the latter: how do I make sure that I have access to the cross-references from within the separate files?

Thank you for taking time to think along with me.

Due to my long experience with Writer in complex context, I am not always very clear.

Copying everything into a single master would contradict the legitimate goal of sorting loosely related matters into a collection of separate documents.


Presently, your *.odt. documents are such that you must copy all common definitions into them with a huge pain to synchronise the changes in the year of the course, deadlines, … It is very easy to forget an update in one document.

image

My suggestions is to turn each individual .odt document into an .odm one so that they can be linked to a single .odt containing the common definitions as:


image

With the master-subdocument feature, any change in the common definitions is automatically forwarded when you open any master.

IMPORTANT!

Don’t confuse the command Insert>Text from File (A) accessible from the menu bar with the contextual Insert>File (B) after a right-click in the Navigator pane in Master view.

(A) copies the file contents into your current document. This means any later update to the source file is not known by Writer and won’t be forwarded.

(B) creates a link between the master and the sub-document and the current contents of the sub-doc is always used to build and format the master.

The choice between both solutions is obvious if you want a dynamic behaviour. Only the master option offers you what you are looking for.

2 Likes

Thank you, @ajlittoz . You clarified exactly what was unclear to me, and I can now use your solution. On behalf of all future teachers, who will edit this course after me: thank you!