# Text Alignment in paragraph box

I'm writing graphic application to generate latex tex. I'm making to generate text box with all it's features. Rotation alignment so on. I generated following cording but It was not Right aligned properly in paragrah box I have shown bounding box. What is wrong there...

\documentclass[a4paper]{article}
\usepackage{pstricks}
\usepackage{xcolor}
\usepackage[arabic,english]{babel}

\begin{document}

\textLR{
\begin{pspicture}(10, 10)
\psgrid
\definecolor{Black}{RGB}{0,0,0}
\rput{0}(3.9,7){%
\psframe[,linestyle=solid,linewidth=0.265mm,linecolor=Black](-2.1,1.9)(2.1,-1.9)
\uput{0.01cm}[320]{0}(-2.1,1.9){%
\parbox[t][3.8cm][t]{4cm}{
\color[rgb]{0,0,0}
\scriptsize
\begin{flushright}
Right Aligned
\newline Right Aligned
\newline Right Aligned
\newline Right Aligned
\newline Right Aligned
\newline Right Aligned
\newline Right Aligned
\newline Right Aligned
\newline Right Aligned
\newline\end{flushright}
}
}
}
\end{pspicture}}

\end{document}

-
Welcome to TeX.sx! –  mafp Mar 7 '13 at 14:53
for some reason, the bounding box doesn't show up for me. adding \null\hfill to the beginning of one line and \hfill\null to the end of another does show that everything else is centered. but why that is happening is a mystery to me. –  barbara beeton Mar 7 '13 at 15:12

## 1 Answer

flushright environment calls \raggedleft which locally redefines \\ to make a ragged break, but it does not redefine \newline. If you change all your \newline to \\ the text goes to the right edge of the box.

-
Thank you for your answer.The Problem solved.But always I got error indicating "!Latex Error : There is no line here to end". Why that is showing. –  Text Alignment Mar 10 '13 at 10:41
@TextAlignment That usually means you have \\  at the start of a paragraph you can't force a line break when you have not started a line yet. –  David Carlisle Mar 10 '13 at 10:42
\parbox[t][3.8cm][t]{4cm}{ \color[rgb]{0,0,0} \scriptsize \raggedleft \\ Right Aligned Text \\ Right Aligned Text } Appreciate your quick response. If I do like this \\ in beginning of line paragraph. Generate same error. –  Text Alignment Mar 10 '13 at 11:01
well there you have \\  before Right Aligned Text which is an error. Also you will get the alignment wrong if you start with \color at the start of a \parbox use \mbox{}\color for technical reasons explained in the grfguide documentation that comes with latex. –  David Carlisle Mar 10 '13 at 11:24