[Tex/LaTex] Changing the left page margin to center text

horizontal alignment

In the MWE below I want to center te text. But I want for each paragraph that the text starts on the same line as the previous paragraph. So using \center is not option. How can this be done?

\documentclass{report}
\begin{document}

\chapter{chaptername}

This text I want to have centered\\

And this this sentence should start on the same line as the previous one.

\end{document}

Best Answer

I guess you're looking for varwidth; remove \raggedright if it's not what you want for the text inside pcenter.

\documentclass{report}
\usepackage{varwidth}
\usepackage{lipsum}% for context

\newenvironment{pcenter}
 {\begin{center}\begin{varwidth}{\textwidth}\raggedright}
 {\end{varwidth}\end{center}}

\begin{document}

\chapter{chaptername}

\lipsum[2]

\begin{pcenter}
This text I want to have centered

And this this sentence should start on the same line as the previous one.
\end{pcenter}

\lipsum[3]

\end{document}

enter image description here