Text Box or Frame autosize and set horizontal position

Within Writer, I’m trying to create either text boxes or frames for showing sections of code. I want them to resize automatically to fit their contents (which doesn’t seem to be an option for text boxes in my version) and have them positioned 0.5" from the left margin (which doesn’t seem to be an option for a frame style in my version).
Anyone have any ideas?

Version: 7.4.7.2 (x64) / LibreOffice Community
Build ID: 723314e595e8007d3cf785c16538505a1c878ca5
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: default; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

Frame ended up being the solution. I found where I was going wrong. Under Position, I had not switched “Horizontal” off its default “Center”, so the “by” box was disabled. Once I switched it to “From Left”, I could enter 0.5" and accomplish what I wanted. One thing I discovered, though, was that AutoSize on width is buggy and made it much wider than it needed to be, so rather than having the width autosize, I calculated the width that would reach just to the right edge of the paragraph area. (In my case, for a letter-sized page in portrait orientation with 0.75" margins, it ended up being a paragraph area width of 7" minus the 0.5" I had it set off the left edge of the paragraph area, or 6.5".)

If you need a full width insertion, is it really necessary to use frames? You could as well type your code snippets and give them an ad hoc paragraph style with a 0.5in left indent. No using frame will avoid you issue with page breaks, i.e. your code snippet can the straddle a page break.

My thinking was that frames with a style would be “cleaner” in the sense that their formatting and how they interacted with the text around them would be more consistent. My preference would be to not allow code snippets to straddle a page break.

Be aware that mastering frames (and their styles) is much more difficult than using paragraph styles.

To give you an idea with using paragraph styles, see X-ACUM-1.1-en_GB-0-p23.pdf (53.0 KB)

Don’t use text boxes. Text boxes are graphical shapes which are totally alien to any text flow. As graphical shapes, all their properties are frozen at creation time.

What you really need is text frames which create sort of sub-documents (limited to the current page height). Inside frames, all formatting primitives are available, notably paragraph and character styles.

You anchor your frames to the relevant paragraph which refere to them. Don’t be tempted to anchor them to page. This mode is a faux-ami which is reserved for very special uses, DRP-like ones. Anchoring to paragraph means the frame will follow the paragraph when you edit your document and the frame will be laid out in the same page as the paragraph.

Once you have anchored it, you can position it anywhere in the page. Either modify the frame style (go to the Type tab) or right-click on the frame and Properties (go to the Position & Size tab).

In the Position section, choose a reference position. In your case this will be horizontally Paragraph Text area and either Left (for alignment on the left indent) of Fram left with your desired distance.

Choose also a consistent wrap mode in Wrap to avoid splitting your text if not wanted. After is probably your best bet.

Thanks! There’s some really good info there.