Como colocar uma régua vertical entre colunas do Beamer criadas com o comando \column?

Como colocar uma régua vertical entre colunas do Beamer criadas com o comando \column?

Nota: Esta questão é diferente dehttps://tex.stackexchange.com/a/95188/18588porque essa pergunta funciona com o columnambiente, mas esta é sobre o \columncomando.

Meu código:

\documentclass{beamer}
\begin{document}

\begin{frame}
\frametitle{Lorem Ipsum}
\begin{columns}[t]
  \column{.5\textwidth}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
  eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
  ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
  aliquip ex ea commodo consequat.

  \column{.5\textwidth}
  Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
  cupidatat non proident, sunt in culpa qui officia deserunt mollit
  anim id est laborum.
\end{columns}
\end{frame}

\end{document}

Isso cria um slide com duas colunas. Quero agora colocar uma linha divisória entre as duas colunas. Eu vi essa resposta emhttps://tex.stackexchange.com/a/95188/18588já e isso funciona bem com \begin{column}e \end{column}. Como posso fazê-lo funcionar \columnapenas com o comando?

Responder1

Aqui está uma solução alternativa a que cheguei:

\documentclass{beamer}
\begin{document}

\begin{frame}
\frametitle{Lorem Ipsum}
\begin{columns}[T]
  \column{.49\textwidth}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
  eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
  ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
  aliquip ex ea commodo consequat.

  \column{.01\textwidth}
  \rule{.1mm}{.7\textheight}

  \column{.49\textwidth}
  Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
  cupidatat non proident, sunt in culpa qui officia deserunt mollit
  anim id est laborum.
\end{columns}
\end{frame}

\end{document}

Aqui está a saída:

Captura de tela da saída

Aqui estão as alterações feitas no código original fornecido na pergunta:

  • A opção tpara o columnsambiente foi alterada para T. Aqui está uma descrição desta opção doGuia do usuário do Beamer(Seção 12.7: Dividindo um quadro em múltiplas colunas):

    Té semelhante à topção, mas Talinha os topos das primeiras linhas enquanto talinha as chamadas linhas de base das primeiras linhas. Se coisas estranhas parecerem acontecer em conjunto com a topção (por exemplo, se um gráfico “cair” repentinamente com a topção em vez de “subir”), tente usar esta opção.

  • A largura das duas colunas contendo texto foi reduzida de .5\textwidthpara .49\textwidthpara liberar espaço para uma nova coluna de largura .01\textwidth. Esta nova coluna é colocada entre as duas colunas de texto existentes. Esta nova coluna conteria a regra vertical.

  • Uma regra vertical foi adicionada na nova coluna com o \rulecomando. Aqui está uma descrição do \rulecomando deA introdução não tão curta ao LATEX 2ε(Seção 6.7: Regras):

    Algumas páginas atrás você deve ter notado o comando

    \rule[lift]{width}{height}
    

    Em uso normal, produz uma caixa preta simples.

    \rule{3mm}{.1pt}%
    \rule[-1mm]{5mm}{1cm}%
    \rule{3mm}{.1pt}%
    \rule[1mm]{1cm}{5mm}%
    \rule{3mm}{.1pt}
    

    Captura de tela da figura na Seção 6.7 de lshort.pdf

    Isto é útil para desenhar linhas verticais e horizontais. A linha na página de título, por exemplo, foi criada com um \rulecomando.

Responder2

Editar: Aqui está uma redefinição das colunas do ambiente e seu comando de coluna para conter linhas verticais entre as colunas com a ajuda de tikz overlay.

A maneira que usei foi adicionando a \tikzmarkao início de cada coluna e depois calculando o ponto médio entre este \tikzmark + a largura do comando e o da próxima coluna \tikzmark. Também usei um truque semelhante para calcular a altura do columnsambiente (redefinido).

Meu columnsambiente recebe um argumento opcional com três opções diferentes separadas por vírgula:

  1. A primeira é a opção de alinhamento do \oldcolumsambiente (como tpara colunas superiores, binferiores e ccentralizadas com alinhamento vertical)
  2. A segunda opção é a largura da linha vertical que será adicionada (após a segunda compilação -porque é adicionada como excesso-) entre as colunas.
  3. A terceira opção é a cor das linhas verticais acima.

Você pode adicionar 1, 2 ou 3 opções neste argumento opcional, mas a ordem deve ser a acima.

O código final:

\documentclass[8pt]{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcounter{mycolcounter}
\newcounter{mylinecounter}
\newcounter{tempcounter}
\newcounter{tempcounterB}
\newlength\availafter
\newlength\initialtextwidth

\newcommand\tikzmark[1]{\begin{tikzpicture}[overlay,remember picture]\coordinate (#1);\end{tikzpicture}}

\newcommand\DrawLines[3]{\draw[line width=\ArgB,color=\ArgC]let\p1=(#1),\p2=(#2),\p3=(#3)in($(\x1,0)+({(\x2+\x3+\csname ColWidth\Alph{tempcounter}\endcsname)/2},\y1)$)--($(\x1,0)+({(\x2+\x3+\csname ColWidth\Alph{tempcounter}\endcsname)/2},{\textheight-\availafter})$);}


\newcommand\lcolumn[1]{\stepcounter{mycolcounter}\setlength\textwidth{\initialtextwidth}\xdef\temp{\the\dimexpr#1}\expandafter\expandafter\expandafter\global\expandafter\let\csname ColWidth\Alph{mycolcounter}\endcsname\temp\oldcolumn{#1}\tikzmark{ColStart\Alph{mycolcounter}}}

\let\oldcolumns\columns%
\let\endoldcolumns\endcolumns%
\renewenvironment{columns}[1][c]{%
\xdef\ArgA{c}%
\xdef\ArgB{1pt}%
\xdef\ArgC{black}
\xdef\Arg{#1}%
\setlength{\initialtextwidth}{\textwidth}%
\tikzmark{ColStart}%
\setcounter{mycolcounter}{0}%
\setcounter{mylinecounter}{0}%
\foreach \k[count=\m from 0] in \Arg {\ifnum\m=0\xdef\ArgA{\k}\else\ifnum\m=1\xdef\ArgB{\k}\else\xdef\ArgC{\k}\fi\fi}
\oldcolumns[\ArgA]\let\oldcolumn\column\let\column\lcolumn%
}{%
\endoldcolumns%
\setcounter{mylinecounter}{\numexpr\the\value{mycolcounter}-1\relax}%
\setlength{\availafter}{\dimexpr\textheight-\pagetotal\relax}%
\setcounter{tempcounter}{0}%
\setcounter{tempcounterB}{1}%
\foreach \col[count=\i from 0]in{1,...,\arabic{mylinecounter}}{%
\stepcounter{tempcounter}%
\stepcounter{tempcounterB}%
\begin{tikzpicture}[overlay,remember picture]%
\DrawLines{ColStart}{ColStart\Alph{tempcounter}}{ColStart\Alph{tempcounterB}}%
\end{tikzpicture}%
}%
\let\column\oldcolumn%\
}


\begin{document}

\begin{frame}
  \frametitle{Lorem Ipsum}

  \begin{columns}
           \column{0.25\textwidth}%
          \noindent1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
          \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
          \column{0.25\textwidth}%
          \noindent1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
      \column{0.25\textwidth}%
      \noindent1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
\end{columns}

    \begin{columns}[c,0.1pt,blue]
      \column{0.3\textwidth}%
      1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
      \column{0.4\textwidth}%
      1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
      \column{0.2\textwidth}%
      \large 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
      \end{tikzpicture}
    \end{columns}

    \begin{columns}[b,0.3pt]
          \column{0.33\textwidth}%
          1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
      \column{0.43\textwidth}%
      \scriptsize1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
      \column{0.23\textwidth}%
      1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
      \end{tikzpicture}
    \end{columns}

        \begin{columns}[t,2pt,green]
          \column{0.23\textwidth}%
          1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
      \column{0.23\textwidth}%
      \footnotesize 1 1 1 1 1 1  1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
      \column{0.23\textwidth}%
      1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
      \end{tikzpicture}
        \end{columns}

\begin{columns}[c,2pt,red]
          \column{0.23\textwidth}%
          \tiny1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
      \column{0.53\textwidth}
      1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\
      \begin{tikzpicture}[inner sep=0,outer sep=0]
        \draw[<->] (0,0)--(\textwidth,0);
        \end{tikzpicture}
    \end{columns}

   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
\end{frame}

\end{document}

Saída:

insira a descrição da imagem aqui

informação relacionada