Skip to content

How to use %SG_NEXT RECORD%

Berteh edited this page Apr 29, 2021 · 3 revisions

The feature to have multiple records on a single page or in a single document does work, but is quite tricky, partially due to the Scribus SLA format and partially to implementation choices for speed.

This page gathers tips and examples. Your contribution is welcome to improve this documentation, as well as to suggest and/or implement improvements to this feature.

Short walkthrough for multiple records from scratch

Some day a screencast might cover the topic, but in the meanwhile below is Berteh's way of doing templates with multiple records:

  1. create one item fully laidout
  2. add %SG_NEXT-RECORD% before the first element of this item, make it smaller if it's touching a text element so Scribus makes it a different (ITEXT) element entirely, that will be cleaned entirely by the script
  3. Check source code in XML editor to make sure SG_NEXT-RECORD is indeed located before any other variable in the source code (both in sequence AND in hierarchy, to be sure, siblings and children are OK, but no other variable should be in an ancestor of it.)
  4. Back in Scribus, group all elements of item (ctrl+g)
  5. Menu item > mutliple duplicate to duplicate as much as needed (even multiple rows)
  6. Retouch style if needed (eg ungroup to alternate colours, then regroup items separately)
  7. ungroup first element of page (ctrl+shif+g) to remove it's SG_NEXT-RECORD marker, as leaving it would skip the first record (of each page).

Run the generator script with appropriate data in "merge" mode, and enjoy the nice work result:

For inspiration, the related source files (remove txt extension), with dynamic pdf link annotations for 2 phones and mails, pictures (original discussions)

Another approach by @UltraSalem, for a cards deck

A short step-by-step guide to create your cards deck, by @UltraSalem, as used for his beautiful Kings of War Vanguard cards:

  1. Build your card and card back once.
  2. Ensure a text box appears on the card somewhere containing %SG_NEXT-RECORD%.
  3. Raise the %SG_NEXT-RECORD% text box to be the highest level using the up arrow in the properties box.
  4. Select all and group all the card elements together.
  5. Item menu -> multiple duplicate. Make it repeat an additional 3 times to fill the page with 4 cards. 1.5mm vertical gap.
  6. Select each card group and ungroup them in turn.
  7. Remove the %SG_NEXT-RECORD% text box from the last card. The script knows to go to the next record at the end of the single page automatically.

For some reason it gets all wonky if the card elements are still grouped when running the script, output only starting half way down the first page, and every other page was blank.

Other examples

Monsters Game Cards

A full example to generate Monsters Game Cards based on Dungeon World is available in the MonsterCards directory, created by Dustin Andrews:

Illustration: Example card deck of monsters, by Dustin Andrew

FAQ

Does level make a difference, for advanced layout, groups and layers

It seems the Scribus SLA format orders items based on their Level in Scribus... and thus Scribus Generator too.

For advanced layouts (groups, layers,...) we thus recommend to put your main item on the first level, together with the %SG_NEXT-RECORD% token before you group them together, for it to behave properly (assuming you call next record at the beginning of your 2nd item and next ones).

Does grouping make a difference?

It appears not, as Scribus stores the group as XML element attribute and not as a hierarchy.

I just group them because it makes the layout of repeating elements a breeze with the "multiply" and "align and distribute" features. Really nice things in there to either glue things with no spacing, or spacing them evenly, align, spread... you name it.

But maybe it does in more recent Scribus versions as Grouping and then Ungrouping elements seems to changer their sequence in the SLA source file... but sometimes only.

Why is it so tough ?

The %SG_NEXT-RECORD% is processed as soon as it is met in the sequential order of the lines in the SLA template source code... because at the time of implementing it Scribus did not properly use the XML elements hierarchy for groups.

Combined with the fact that elements are stored in the SLA more or less in their order of creation rather than graphical position it becomes really difficult. I usually resort to moving the element containg the %SG_NEXT-RECORD% manually in the SLA code if fixing it seems difficult.

We needed a mechanism that could fit any layout (left-right, right-left, top-bottom, multiple rows or columns, you name it), and would integrate with the Scribus user interface without changes. Any improvement idea is welcome, simply (create a new issue).

History

Changes in NEXT-RECORD syntax

Please note Scribus Generator v2.8 (from January 2019) changed the syntax of the "Next Record" feature to a less confusing name, as per suggestion #118

Update your older templates manually, changing %VAR_NEXT-RECORD% to %SG_NEXT-RECORD%, or all at once by calling, for instance:

python ./ConvertVAR_NEXT-RECORDToSG28.py ~/ScribusProjects/*/*.sla