15

I can get text justification in blocks by using \justifying. Is it possible to justify the text within each block globally without using \justifying in each block? Thanks

MWE

\documentclass{beamer}
\usetheme{default}


% For global Justification
%\usepackage{ragged2e}
%\justifying
\renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm} 


\begin{document}


\begin{frame}{Test}

\begin{block}{Test}
The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog.
\end{block}

\end{frame}


\end{document}
lockstep
  • 250,273
MYaseen208
  • 8,587

2 Answers2

34

you could load the ragged2e package and add a \justifying at the end of the block begin template:

\documentclass{beamer}
\usepackage{ragged2e}   %new code
\usetheme{default}

\addtobeamertemplate{block begin}{}{\justifying}  %new code

\begin{document}
    \begin{frame}{Test}
        \begin{block}{Test}
            The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog. The brown fox jumped over the lazy dog.
        \end{block}
    \end{frame}
\end{document}

enter image description here

d-cmst
  • 23,095
0

In my case the code given by domenico camasta didn't work. But the following modification works

\documentclass{beamer}
\usepackage{ragged2e}
\usepackage{lipsum}
\addtobeamertemplate{block begin}{}{\justifying}{}

For justifying texts out side the blocks, I used the following command along with the above codes:

\apptocmd{\frame}{}{\justifying}{}
Werner
  • 603,163
Anit
  • 37
  • 4
    Your suggestion doesn't add anything that isn't already covered by the existing answer. I can't see how it wouldn't work in the first place. – Werner Jun 04 '18 at 05:31