Conditional text
In Word the only way
to have conditional text is with the “if” field.
The equivalent in Writer is the field “Conditional text”.
To
insert a conditional field in Writer: Insert
> Fields > Other > Functions > Conditional text or
Control+F2
> Functions >
Conditional text.
There
is also a field “Hidden text” that hides the text when the
condition is true.
Working
with the relevant fields for conditional text, both in Word and in
Writer, means that only small amounts of text can be conditional.
However, there are times when having whole paragraphs or sections of
text be conditionally hidden is very convenient. Some examples:
A
test so that the same document can be used for the test itself and
for the model answers.
Technical
documents where the same document with variations can be used for
similar models of equipment.
Writer
provides a field for conditionally hiding paragraphs and the ability
to conditionally hide sections. Here is
an example to show how this could be done:
Ensure
that hidden text is viewable: Tools
> Options > OpenOffice.org Writer > Formatting Aids,
select both “Fields: Hidden text” and “Fields: Hidden
paragraphs”.
Note
|
Conditionally
hidden sections are not visible regardless of these settings if
the condition for hiding them is true.
|
At
the top of the document: Insert
> Fields > Other > Variables.
Name:
DocType. Value: Model Answers.
At
the start of a one paragraph answer: Insert
> Fields > Other > Functions > Hidden Paragraph.
For the condition type DocType == “Test” (To make this easier to
insert repeatedly, create an autocorrect entry).
For
longer answers: Enter the model answer, select it, Insert
> Section, select Hide, and enter DocType == “Test”
for the condition.
To
print the document for a test, double-click the field at the top of
the document created in steps 2 and 3, and change the value to Test.
Print as usual.
Note
1
|
The
field “Input list” has a name but this is not a variable so
its value cannot be used in the condition.
|
Note
2
|
To
keep adding sections, it is easier if the selection does not
include the last paragraph. But if the last paragraph is selected,
simply move to the end of the document (Control+End
) and then press Alt+Enter.
|