A very similar, but significantly different question is LyX command(s) to insert WYSIWYG horizontal line, for keyboard shortcut.

I'm trying to achieve the effect of \hrulefill in LyX, without resorting to an ERT (TeX code inset).

The example is the following:

Name and section:\enspace\hrulefill

All of the Width: options for Insert>Formatting>Horizontal Rule don't seem to achieve the same effect as \hrulefill, since they require a % of, or some fixed width, and aren't as dynamic. Is there some way to achieve this using the LyX interface?


Insert ▷ Formatting ▷ Horizontal space.

Spacing: horizontal fill

Fill pattern: __________

  • This truly generates the LaTeX code for \hrulefill. However, the feedback in the document is not so clear (I just see a vertical bar). If I add a character after, LyX will draw the underline all the way to the right margin (where my character also is). Is there a way to make it more obvious in the GUI without adding that character? Perhaps this is a LyX bug? Jul 25 '16 at 15:02

You can add a Custom Inset by adding to your Document > Settings... > Local Layout

Format 49
InsetLayout "Flex:HRuleFill"
    LyXType          Custom
    LabelString      HRuleFill
    LatexType        Command
    LatexName        hrulefill
    Decoration       classic
        Color        blue
        Size         Small
    ResetsFont true

This should add an HRuleFill inset:

enter image description here

It's similar in nature to an ERT in my opinion.

  • Is there a way to have an inset that is either "closed" by default or doesn't allow content? Non-technical users could think they should type something into the inset. Perhaps by mapping a shortcut? I realize this wasn't part of my initial question. Jul 23 '16 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.