Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,502
Community Members
 
Community Events
165
Community Groups

Confluence User Macro to justify text

Hello,

I would like to write a user macro very simple in order to justify text. How I can do ?

thanks in advance

2 answers

1 accepted

2 votes
Answer accepted

hi @Nico n,

Try below code and let me know whether this helps ☺️ 

## Developed by: Alana Fernando
## Date created: 19/04/2018
##Shared with love...



<div>
<p class="txtAlgn">
$ {body}
</p>
</div>

<style>

.txtAlgn{
text-align :justify;
}

</style>

Select Rendered as macro body processing. 

Here is a much more improved version of above code.

## @param alignment:title=Text alignment|type=enum|desc=Choose Text alignment.|enumValues=Right,Left,Center,Justify

#if ($paramalignment == "Right")

<style>
.txtAlgn{
text-align :right;
}
</style>

#elseif ($paramalignment == "Left")
<style>
.txtAlgn{
text-align :left;
}
</style>

#elseif ($paramalignment == "Center")
<style>
.txtAlgn{
text-align :center;
}
</style>

#elseif ($paramalignment == "Justify")
<style>
.txtAlgn{
text-align :justify;
}
</style>

#end

<div>
<p class="txtAlgn">
$body
</p>
</div>

Many thanks Alana, very useful! :)

I have tried both with some text. They partially works, so that if I write only a paragraph then it is correctly justified, otherwise if I write two or more paragraphs, then it doesn't justify text anymore.

For example see: 

https://doc.helab.nuvolaitaliana.it/display/AEE/prova+condivisione+2

Anyway this macro is very useful and I appreciated a lot. Thanks :)

@Nico n try below change in above code. it should surely solve this issue. 

<div class= "txtAlgn">
<p>
$body
</p>
</div>

Where should we add this code?

Hi Nico,

Adaptavist has created a server-version app that has this macro included:

Content Formatting Macros

If you're trying to do this on Cloud, I don't think it's possible. 

Thank you Meg, I know about this plugin but it is not free. I need to write a user macro (very simple) only to justify text.

thank you anyway

I've found only that you can do this with the HTML macro utilizing justify code. 

Obviously it's possible since Adaptavist has figured it out, but I'm not able to assist with that. 

thanks anyway :)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

197 views 1 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you