Special Characters and Paragraph Breaks

Hi Again,

New question. I am using Overleaf right now to process the latex document/commands that come out of Scrivener.

I am having two little issues (which may not really be Overleaf specific).

  1. Paragraphs need to have a blank link between them.
  2. Special characters (especially, but not limited to %)

I’ve already ready somewhere that you must mark the end of your paragraphs for LaTex not to run them together.

Adding a black line between them works for me.

How can I make Scrivener do this automatically (assuming one Scrivener layout might have many paragraphs … if each paragraph is a section it’s easy of course … but that’s not really workable with my co-writers or me. :).

Maybe there’s a regular expression replacement that does this, but I’ll never understand regular expressions … and I took an entire college-level class on them (aced the class 4.0, but that’s the last time I understood them :D). Or there is probably a well-known way I’m not landing on.

There is some kind of line-ending replacement in the standard LaTex package with Scrivener. But it’s doing nothing for me. It literally has no effect when I compile. I might have missed something.

As far as the special characters … there must be a good way to handle them too, but I haven’t landed on that either.

I noticed there’s a % replacement, it’s definitely not doing what I expect, so I think I’m missing something key.

Thanks again for the help.
Cheers,
Steve

Regarding paragraph formatting, I believe this post outlines the technique you are looking for. As noted there, the good news is that the built-in Markdown compile formats are all set up for it, you just have to make a couple of adjustments to tell the compiler that’s what you want.

With special characters, I presume you mean anything that LaTeX would take as syntax? The standard approach is to use backslash escaping on anything you need to print literally that might be taken as syntax otherwise, so \% in that case.

Amber,

Thanks for your quick response. That’s exactly what I need on paragraph formatting.

But i just I tried it, I selected paragraph spacing in transformation and compiled, but the output is the same. What do you think I might have missed?

Yes, you’re correct on what I meant by the ‘special’ characters. Since I’m compiling documents for different output formats, I wanted to escape them at compile time (change % to % which is why I thought a regex replacement might be the way to go. But I couldn’t find one that worked. Or rather it escaped the % in the “header” files that gets compiled into the latex output too.

Maybe this is where I will need to do something with the markdown formats and pandoc (but I hope not). :slight_smile:

Oh, sorry, I had Markdown in my head from another post, and forget this was LaTeX-related, but that’s fine! We are just speaking of plain-text transformation here, which is applicable to either.

But i just I tried it, I selected paragraph spacing in transformation and compiled, but the output is the same. What do you think I might have missed?

Did you also apply a formatting override in the Section Layouts that output bulk text? All of them would need that, if the source material isn’t visually spaced with paragraph padding.

The other thing to check is looking into the implications of something I went on to talk about, lower in that post, where one could use styled text to force adjacent lines where needed or desired. In other words, if you’re bulk styling body text then that formatting would be passing through any overrides, by design. I can’t think of why you’d ever need a “body” paragraph style in a LaTeX project though (and scarcely ever any need in Scrivener in general, given how its compile system works).

I wanted to escape them at compile time (change % to % which is why I thought a regex replacement might be the way to go. But I couldn’t find one that worked.

For something simple like that, do you even need regex? But if you do, you do need to “slash the slash” in the replacement field, since backslashes are regex syntax. Something like \\% is what you’d need.

Maybe this is where I will need to do something with the markdown formats and pandoc (but I hope not).

Speaking personally, if I needed more outputs than just LaTeX that is certainly the route I’d be taking, as one single simple input format can end up as .tex, .docx, .html or whatever I need. But, it is another way of writing entirely, and probably not something your collaborators will be accustomed to.

Did you also apply a formatting override in the Section Layouts that output bulk text? All of them would need that, if the source material isn’t visually spaced with paragraph padding.

Is there a place to change the default paragraph output? I couldn’t find that. For now I created a new paragraph style which I think applied to everything in the paragraph. But would be cool if I could just say everything that isn’t specifically overridden gets this default override.

I thought so, but now I’m going to have to try again to be sure.

Did you also apply a formatting override in the Section Layouts that output bulk text? All of them would need that, if the source material isn’t visually spaced with paragraph padding.

I was just coming back to say that this worked. Now I have to re-check the other method.

For something simple like that, do you even need regex? But if you do, you do need to “slash the slash” in the replacement field, since backslashes are regex syntax. Something like \\% is what you’d need.

Doesn’t everyone use a regex when they don’t really need one. My issue with doing a simple replace is that it replaced the special characters in the LaTeX code in the front matter and back matter. And that’s where they shouldn’t be escaped. Maybe the raw markup style would help here.

Speaking personally, if I needed more outputs than just LaTeX that is certainly the route I’d be taking, as one single simple input format can end up as .tex, .docx, .html or whatever I need. But, it is another way of writing entirely, and probably not something your collaborators will be accustomed to.

Thank for thinking of that. I appreciate your approach here. I was wondering if she shouldn’t just all move to markdown, but my collaborators aren’t so keen on that right now.

And for now, this seems to be working pure latex :slight_smile: (on the latex output).

But would be cool if I could just say everything that isn’t specifically overridden gets this default override.

There is a file type that works, that way: ePub. There is a CSS pane, and in there you can set a global paragraph default. Then individual Section Layouts can choose to override the global default if they need to, or even pass-thru editor formatting (useful for stuff like dedication pages).

As to why the rest doesn’t—well, I would say you can achieve that if you want, without a dedicated feature for it. Consider:

  1. Go into the Styles compile format pane. Create a “Body” or “Normal” paragraph style and set up its formatting. This is your global fallback default.
  2. In each Section Layout that prints body text, enable formatting override and then apply this style.

That’s more of a WYSIWYG output approach of course, to be clear. For LaTeX we really only need styles for syntax as the preamble and such handles the formatting for us. But if I ever had to dabble in using Scrivener’s WYSIWYG side of things, that’s the hard line approach I’d take: I wouldn’t use any of the formatting tools in Section Layouts. They would exist purely to show were styles are assigned.

I was just coming back to say that this worked. Now I have to re-check the other method.

Okay, yes, you probably will need to roll back some style usage for that to work as expected. You can go the style route, it’s just more busy-work in my opinion, as you then need to add paragraph padding to the Styles pane overrides. It’s a lot easier to just use styles for when you need special purpose text, and that’s the assumption the compiler is built on. And, as explored above, not using paragraph styles in the editor doesn’t mean you can’t end up with them in the output. Sorry, that was a lot of negatives in one sentence. :expressionless:

Doesn’t everyone use a regex when they don’t really need one. My issue with doing a simple replace is that it replaced the special characters in the LaTeX code in the front matter and back matter.

Exactly what I was worried about. I don’t think I could use a global escape replacement in any of my projects, as that would make handling actual syntax a bit of a bother.

Maybe the raw markup style would help here.

Unfortunately it won’t, that doesn’t stop Replacements from running, it only stops Scrivener’s own attempts to escape special characters, if applicable.

Hmm, well one approach would be something I do with Markdown. I have a "Raw LaTeX’ character style that handles a similar issue, but in your case you could just leave the style alone entirely for the .tex format. What you’d want to do special is add that style to the .docx output, and use the checkbox that deletes the styled text. This is a great technique for multi-format outputs where you may, here and there, want to speak more directly to a particular format without syntax ending up in other outputs. In this case you’d only be using it to mark the slash though—not a lot, but just enough.

All great suggestions. Thanks.