There may be a workaround if your “§1” is not random, i.e. if all “§1___Text” paragraphs are numbered sequentially (I mean, “§1” numbers items in a list scattered throughout the document).
You need to define a dedicated paragraph style for this list. For my experiment, I used one derived from Body Text (I named it Insert_into_TOC). In Outline & Numbering
tab, I associated it with Numbering 123 numbering styles (but you may need a dedicated one if this style is already used by another list so that you have no interaction between them) and I linked the paragraph to outline level Level 5.
I linked to outline level 5 because I didn’t use it, but you may link with used levels like 1 or 2 if common formatting in the TOC fits your needs both for the outline and the inserted data.
-
Modify the numbering style (found in the so-called list styles) Numbering 123 so that a HT
(horizontal tab) is automatically added after the number and position it to the required location.
-
Style all your “§1___Text” with Insert_into_TOC and remove the manual “§1” and ___ tab (they are now provided by the list engine).
Edit your TOC (right-click and Edit index
).
- In the
Entries
tab, select level 5 (or the one you chose); click in the white space between E#
and E
and push the Tab stop
button. Define the position in the text box below.
Now you have a tab in the TOC entry and you can play with it.
CAUTION: this tab position cannot be defined in the Contents 5 paragraph style dialog, but only here. That’s important for post-definition tuning.
- Modify Contents 5 to sent indents, spacings, alignment and other attributes.
This is a bit tricky and will likely need several trials before being satisfying.
EDIT 2019-04-04
After reading the referenced document and some experiment, there is no definitive solution. The basic reason, as hinted by @mikekaganski, is that Writer disconnects layouts of headings and TOC entries. Tabs in headings are relative to the Heading n paragraph style and this could cause conflicts with Contents n paragraph style definition in the TOC. As a precaution, tabs and “soft” newlines are removed from the heading and replaced by spaces when entered in the TOC. The situation is even more serious because tab definition in Contents n styles are ineffective. The “real” tabs used to layout the entries are set in Insert
>TOC & Index
>TOC, Index, Bibliography
with the Tab
button.
I can only suggest an ugly workaround.
Your TOC is approximately 10 pages long, so manual editing should be relatively light.
-
Modify the Content n for your special entries as follows in Indents & spacing
tab:
- set the Before text indent to the position where you want “text” to be aligned, e.g. 3cm
- set First line indent to a negative value to offset PatV 999 to the left, e.g. -2cm; take care that this hanging indent is wide enough to handle the largest PatV 999
-
Edit your document as usual. When you’re done, create or update the TOC, unchecking Protected against manual changes. Then replace the space between PatV 999 and text by a tab through Edit
>Find & Replace
:
- in the Find box, enter
(PatV [^ ]+)
, i.e. the fixed prefix PatV, a space, the specification for a sequence of non-space characters and a final space; the parenthesis define a capture range,
- check Match case to avoid false positives
- in the Replace box, enter
$1\t
, i.e. text captures and a tab code
- develop Other options and chack Regular expressions
- then press
Find Next
and Replace
to change occurrence after occurrence, so that you can check the validity of the hit, or Replace All
if you’re confident.
*Nota: you told me that PatV 999 was followed by a tab in the document body. Consequently, it should be followed by a space only in the TOC and Replace All
should only replace there.
This second step must be redone every time you regenerate the TOC, sorry!
To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!