Mobile app version of vmapp.org
Login or Join
Si6392903

: Add a background-color to a paragraph-style in inDesign I am currently creating a book layout with inline code and code-blocks. For those code parts, i would like to add a background-color. It

@Si6392903

Posted in: #AdobeIndesign #Background #CharacterStyles #Formatting #ParagraphStyles

I am currently creating a book layout with inline code and code-blocks.
For those code parts, i would like to add a background-color. It should handle code similar to the way it is displayed on StackExchange.

Codeblocks

As there is no option in paragraph-styles, that would add a background, I tried to use paragraph rules, underline rules, strikethrough rules and some other experimental approaches.

Strikethrough rules
The striketrough rules are displayed above the text, making it completely useless for this purpose.

Underline rules
Underline rules are displayed under the text, which makes it possible to use it as a background. The problem is, that it depends on the character-length. That makes it possible to use it over lines that have an automatic line-break.
The problem is, that you can’t add margins to it and that you can’t insert a background with a fixed width.



Paragraph rules
Paragraph rules are pretty close to a solution. You can determine, if you want the line above, or below your text, you can add margins and the line fills the whole width of the block. The problem here is, that it is a paragraph line, meaning that it adds a rule for the whole paragraph instead of each line. That is no problem if every paragraph is only one line high, but if a paragraph that includes multiple lines, you end up with a gap in the background. I could add a forced line-break here, but I would like to avoid that.



A solution would be, if I could add a forced line-break on the end of each line through a GREP-style, but I haven’t seen any way to add a character this way.

Inline Code

I am using character styles for inline Code. Underline rules seems to be the most appropriate way to go here. The problem is, that I am massing margins here. If I add a space on the beginning and the end of the inline code, I end up with a nice result, but that means I have to add characters to the text, which I would like to avoid and it would not work on the beginning and the end of a line-break, because inDesign deletes the character if it is not needed.



I am searching a way to add some space before and at the end of the inline code.

So, that would be it. I am searching solutions to this problem for a long time now, so any ideas would be appreciated.

Oh and sorry for the crappy image quality. The missing retina display support of inDesign made it possible.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Si6392903

3 Comments

Sorted by latest first Latest Oldest Best

 

@Angela777

Todays Adobe CC Update (2015) brought the solution to this problem.
You can now enable paragraph shading to add a background to paragraph styles.

10% popularity Vote Up Vote Down


 

@Rambettina927

You can use a paragraph rule to block in the whole measure or the text underline to highlight just the text. The trick is to get the offset just right then set a width value that matches or exceeds your leading value.

10% popularity Vote Up Vote Down


 

@Murphy569

I used table for my own report and it worked really good for me. For every code block that I needed, I just did a copy/paste of previous table. For syntax highlighting , I defined character style first but it was tedious to apply those styles for every pieces of code. Therefore just copied the code from IDE, preserving the color and font, to InDesgin. Here is how it looks like:



The only problem is that you cannot copy a block of code and you have to copy and paste line by line since every table row represents one line of code.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme