Make `onlytextwidth` default width of `columns`

You may define a new environment (columnsotw in the example below) that uses onlytextwidth as default option... or you may use the predefined environment columnsonlytextwidth (without any other options)

enter image description here

\documentclass{beamer}
\usepackage{lipsum}

\newenvironment{columnsotw}[1][]{\columns[onlytextwidth,#1]}{\endcolumns}

\def\cola{Abc def ghi jkl mno pqr stu vwx z. Abc def ghi jkl mno pqr stu vwx z.}
\def\colb{Abc def ghi jkl.}

\begin{document}
\begin{frame}[fragile]
  \begin{columns}[onlytextwidth,b]
    \column{.4\linewidth}
    \cola
    \column{.4\linewidth}
    \colb
  \end{columns}
  \vfill
  \begin{columnsonlytextwidth}% [b] ???
    \column{.4\linewidth}
    \cola
    \column{.4\linewidth}
    \colb
  \end{columnsonlytextwidth}
  \vfill
  \begin{columnsotw}[b]
    \column{.4\linewidth}
    \cola
    \column{.4\linewidth}
    \colb
  \end{columnsotw}
  \vfill
  \begin{columns}[b]
    \column{.4\linewidth}
    \cola
    \column{.4\linewidth}
    \colb
  \end{columns}
\end{frame}
\end{document}

Instead of creating a new environment, another possibility is to redefine the columns-environment

\documentclass{beamer}

\makeatletter
\long\def\beamer@newenvnoopt#1#2#3#4{%
    \expandafter\renewcommand\expandafter<\expandafter>\csname#1\endcsname[#2]{#3}%<- here
    \expandafter\long\expandafter\def\csname end#1\endcsname{#4}%
}
\long\def\beamer@newenvopt#1#2[#3]#4#5{%
    \expandafter\renewcommand\expandafter<\expandafter>\csname#1\endcsname[#2][#3]{#4}%<- here
    \expandafter\long\expandafter\def\csname end#1\endcsname{#5}%
}

\renewenvironment<>{columns}[1][]{%
    \begin{actionenv}#2%
        \def\beamer@colentrycode{%
            \hbox to\textwidth\bgroup%
            \leavevmode%
            \hskip-\beamer@leftmargin%
            \nobreak%
            \beamer@tempdim=\textwidth%
            \advance\beamer@tempdim by\beamer@leftmargin%
            \advance\beamer@tempdim by\beamer@rightmargin%
            \hbox to\beamer@tempdim\bgroup%
            \hbox{}\hfill\ignorespaces}%
        \def\beamer@colexitcode{\egroup%
            \nobreak%
            \hskip-\beamer@rightmargin\egroup}%
        \ifbeamer@centered\setkeys{beamer@col}{c}\else\setkeys{beamer@col}{t}\fi%
        \setkeys{beamer@col}{#1, onlytextwidth}% added "onlytextwidth"
        \par%
        \beamer@colentrycode%
        \def\beamer@colclose{}\ignorespaces}%
    {\beamer@colclose\def\beamer@colclose{}\beamer@colexitcode\end{actionenv}}%
\makeatother

\begin{document}
    \begin{frame}
        \begin{columns}[onlytextwidth]
            \begin{column}{.5\textwidth}
                \rule{\textwidth}{1cm}
            \end{column}
            \begin{column}{.5\textwidth}
                \rule{\textwidth}{1cm}
            \end{column}            
        \end{columns}

        \begin{columns}
            \begin{column}{.5\textwidth}
                \rule{\textwidth}{1cm}
            \end{column}
            \begin{column}{.5\textwidth}
                \rule{\textwidth}{1cm}
            \end{column}            
        \end{columns}       

    \end{frame}
\end{document}

enter image description here

Tags:

Beamer

Columns