> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate element relations

> Train element relations from a reference layout in FlexiLayout Studio: pick reference elements, review generated relations, and save the ones you need.

Apart from specifying a [relative search area](/flexi-capture/fls/template/relations) for elements manually, you can also train element relations based on the reference layout of the selected pages.

## Prerequisites for relation training

* The **Reference layout** must contain elements for which relations are to be generated.
* All pages to be included in the training set must be marked as **Use for Training** on the **Batch** tab.

<Note>
  The element being trained must be located lower down the tree of elements than the elements that relations are created with. All elements must be non-recurring.
</Note>

## Generate element relations

<Steps>
  <Step title="Open the Select Element dialog box">
    On the element's shortcut menu, select **Train Element** → **Generate Element Relations**. The **Select Element** dialog box opens.
  </Step>

  <Step title="Choose the elements to generate relations with">
    Add the elements to the right side of the window by clicking <img src="https://mintcdn.com/abbyy/fmgRWFNHKYN2MLSg/images/flexi-capture/fls/Button_Right.gif?fit=max&auto=format&n=fmgRWFNHKYN2MLSg&q=85&s=e5bbccc3203ef5f931d294c79aa2293f" alt="Add selected element button" style={{display:"inline-block",verticalAlign:"middle",margin:0}} width="27" height="18" data-path="images/flexi-capture/fls/Button_Right.gif" /> (to add a selected element) or <img src="https://mintcdn.com/abbyy/fmgRWFNHKYN2MLSg/images/flexi-capture/fls/Button_All_Right.gif?fit=max&auto=format&n=fmgRWFNHKYN2MLSg&q=85&s=749dfbf28d3479073569e0b2fb77236b" alt="Add all elements button" style={{display:"inline-block",verticalAlign:"middle",margin:0}} width="27" height="18" data-path="images/flexi-capture/fls/Button_All_Right.gif" /> (to add all available elements), or by double-clicking an element. The selected elements are highlighted in bold on the left side of the window.
  </Step>

  <Step title="Click OK">
    The **Choose Trained Element Relations** dialog box opens. It contains three lists:

    * **Reference elements** – The elements that relations have been created with.
    * **New Relations** – New relations obtained from training.
    * **Old Relations** – Previously created relations.

    <Frame>
      <img src="https://mintcdn.com/abbyy/r-nfa7jujx5b9gKX/images/flexi-capture/fls/relation_generate.PNG?fit=max&auto=format&n=r-nfa7jujx5b9gKX&q=85&s=369be3f245e1a333d8400c3cdb3d51a3" alt="Screenshot of the Choose Trained Element Relations dialog box, showing the Reference elements list alongside the New Relations and Old Relations lists with their relation types, reference boundaries, and offset values." width="495" height="408" data-path="images/flexi-capture/fls/relation_generate.PNG" />
    </Frame>
  </Step>

  <Step title="Preview a relation on the image">
    Select a relation in the list to view its visualization in the **Image** window. The reference element in the **Image** window is enclosed in a thick frame and the search area is highlighted with a green background.

    <Note>
      When selecting several relations, the intersection of the selected relations is displayed. The intersection area is highlighted with a green background, while the areas outside the intersection borders are highlighted in blue.
    </Note>
  </Step>

  <Step title="View relations on other pages of the training set">
    To view visualized relations on the next or previous page from the training set, click <img src="https://mintcdn.com/abbyy/fmgRWFNHKYN2MLSg/images/flexi-capture/fls/Button_All_Left.gif?fit=max&auto=format&n=fmgRWFNHKYN2MLSg&q=85&s=6f3826db16635949999496b43c4dde6e" alt="Previous page button" style={{display:"inline-block",verticalAlign:"middle",margin:0}} width="27" height="18" data-path="images/flexi-capture/fls/Button_All_Left.gif" /> and <img src="https://mintcdn.com/abbyy/fmgRWFNHKYN2MLSg/images/flexi-capture/fls/Button_All_Right.gif?fit=max&auto=format&n=fmgRWFNHKYN2MLSg&q=85&s=749dfbf28d3479073569e0b2fb77236b" alt="Next page button" style={{display:"inline-block",verticalAlign:"middle",margin:0}} width="27" height="18" data-path="images/flexi-capture/fls/Button_All_Right.gif" /> in the bottom left corner of the window respectively. To go to the page with a specified number, click the **Go to Page...** button.
  </Step>

  <Step title="Save the relations">
    Select the checkbox next to the relations you want to use and click the **Save Changes** button.
  </Step>
</Steps>
