2

I need to use resizebox over verbatim mode. Is there a conflict between usage of verb mode inside a resizebox? If you look at the first column of the table, it always add | at the end of each text. I have no idea about that. If I do not put in a resizebox, there is no issue as they are attached.enter image description here

How I can fix this issue ?

\documentclass{beamer}
\begin{document}


\frame{Operatorler}
    \resizebox{\textwidth}{!}{
    \begin{tabular}{lll}
        \textbf{test}  & \textbf{test}   &   \textbf{test}\\
        \verb|+|  & toplama     & a\\
        \verb|−|  & çıkarma     & a\\
        \verb|*|  & çarpma      & a\\
        \verb|/|  & bölme       & a\\
        \verb|%|  & bölme sonrası kalan (mod alma işlemi)   & a\\
        \verb|++| & artırma     & a\\
        \verb|--| & azaltma     & a\\
    \end{tabular}
    } % end of scope of "\resizebox"  directive
    \framebreak

    \begin{tabular}{lll}
        \textbf{test}  & \textbf{test}   &   \textbf{test}\\
        \verb|+|  & toplama     & a\\
        \verb|−|  & çıkarma     & a\\
        \verb|*|  & çarpma      & a\\
        \verb|/|  & bölme       & a\\
        \verb|%|  & bölme sonrası kalan (mod alma işlemi)   & a\\
        \verb|++| & artırma     & a\\
        \verb|--| & azaltma     & a\\
    \end{tabular}
\end{document}

It generates:

1
  • 1
    you can not use verb in any command, but also avoid using \resizebox on tables, you give up any hope of consistent fonts or reasonable typography by squishing the table in this way. If you really must do it then avoid leaving a space at each end of the resizebox – David Carlisle Nov 7 '20 at 16:37
2

You can't use \verb in the argument to another command, so you can't do \resizebox if the material contains \verb.

However, you can first make the box and then resize it.

\documentclass{beamer}

\newsavebox{\tablebox}

\begin{document}

\begin{frame}[fragile]
\frametitle{Operatorler}

\begin{lrbox}{\tablebox}
    \begin{tabular}{lll}
        \textbf{test}  & \textbf{test}   &   \textbf{test}\\
        \verb|+|  & toplama     & a\\
        \verb|-|  & çıkarma     & a\\
        \verb|*|  & çarpma      & a\\
        \verb|/|  & bölme       & a\\
        \verb|%|  & bölme sonrası kalan (mod alma işlemi)   & a\\
        \verb|++| & artırma     & a\\
        \verb|--| & azaltma     & a\\
    \end{tabular}
\end{lrbox}
\resizebox{\textwidth}{!}{\usebox{\tablebox}}

\end{frame}

\end{document}

enter image description here

I changed the (U+2212), that doesn't really make sense in that context, with a hyphen.

Do you really need to resize the table anyway? If it turns out to be wider than the text width, using a smaller font is better.

I'd recommend to also avoid the syntax

\frame{Title}{
  <contents>
}

and to use the better syntax

\begin{frame}
\frametitle{Title}
<contents>
\end{frame}

that also allows to add options such as fragile (for when the frame contains verbatim material).

Also, \verb can be avoided altogether and

    \begin{tabular}{lll}
        \textbf{test}  & \textbf{test}   &   \textbf{test}\\
        \texttt{+}  & toplama     & a\\
        \texttt{-}  & çıkarma     & a\\
        \texttt{*}  & çarpma      & a\\
        \texttt{/}  & bölme       & a\\
        \texttt{\%}  & bölme sonrası kalan (mod alma işlemi)   & a\\
        \texttt{++} & artırma     & a\\
        \texttt{--} & azaltma     & a\\
    \end{tabular}

would have the same output. Only % needs to be escaped.

4
  • \texttt{+} not \texttt|+| I guess you meant:-) – David Carlisle Nov 7 '20 at 16:41
  • @DavidCarlisle Possibly. ;-) – egreg Nov 7 '20 at 16:53
  • @egreg Many thanks for entire explanations. I am not sure about this part: "If it turns out to be wider than the text width, using a smaller font is better." > Do you mean instead of resizing the whole table, I should play with text width to fit into page ? On the other hand, I am completely not confident with box side, so not fully understand what you did there such as newsavebox, lrbox, tablebox. However, I will focus on this side to understand it more deeply. By the way, if you could add a little bit more comments on your tablebox solution, it might speed up my understanding. Thanks again! – ozturkib Nov 9 '20 at 8:50
  • @ozturkib You should play with font size, so that the table fits. The main idea around \tablebox is to save the tabular in a box and using lrbox avoids the problem with \verb. Then the box can be used in various ways, for instance to scale it. – egreg Nov 9 '20 at 9:25
2

You can use verbatimbox to save the content as a box, even before entering the frame.

\documentclass{beamer}
\usepackage{verbatimbox}
\begin{document}
\begin{myverbbox}{\Percent}%\end{myverbbox}

\begin{frame}
\frametitle{Operatorler}
\resizebox{\textwidth}{!}{%
\begin{tabular}{lll}
    \textbf{test}  & \textbf{test}   &   \textbf{test}\\
    \texttt{+}  & toplama     & a\\
    \texttt{-}  & çıkarma     & a\\
    \texttt{*}  & çarpma      & a\\
    \texttt{/}  & bölme       & a\\
    \Percent  & bölme sonrası kalan (mod alma işlemi)   & a\\
    \texttt{++} & artırma     & a\\
    \texttt{--} & azaltma     & a\\
\end{tabular}
}
\end{frame}
\end{document}

enter image description here

2
  • As you demonstrated on your output, it cannot produce the desired output. It just prints latex code ? Is it just because of \theverbbox definition ? – ozturkib Nov 9 '20 at 8:53
  • @ozturkib I apologiize for misinterpreting things to begin with. I have edited the answer to provide what I think you are looking for. – Steven B. Segletes Nov 9 '20 at 10:08
0

Instead of trying to resize the table to make it as wide as the textwidth, I increased the font size to \large and used tabular* in combination with \extracolsep{\fill}}:

enter image description here

\documentclass{beamer}

\begin{document}

\begin{frame}[fragile]
\frametitle{Operatorler}
\large
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lll}
        \textbf{test}  & \textbf{test}   &   \textbf{test}\\
        \verb|+|  & toplama     & a\\
        \verb|-|  & çıkarma     & a\\
        \verb|*|  & çarpma      & a\\
        \verb|/|  & bölme       & a\\
        \verb|%|  & bölme sonrası kalan (mod alma işlemi)   & a\\
        \verb|++| & artırma     & a\\
        \verb|--| & azaltma     & a\\
    \end{tabular*}

\end{frame}

\end{document}

Without the use of \verb but with \ttfamily:

\documentclass{beamer}
\usepackage{array}
\begin{document}

\begin{frame}
\frametitle{Operatorler}
\large
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}>{\ttfamily}lll}
        \sffamily\textbf{test}  & \textbf{test}   &   \textbf{test}\\
        +  & toplama     & a\\
        -  & çıkarma     & a\\
        *  & çarpma      & a\\
        /  & bölme       & a\\
        \% & bölme sonrası kalan (mod alma işlemi)   & a\\
        ++ & artırma     & a\\
        -- & azaltma     & a\\
    \end{tabular*}

\end{frame}

\end{document}
2
  • Thanks for the effort but it is not what I am aiming as it is pointed in the question. For instance, if the content of each cell is getting bigger, this will not display it because it is not actually resizing the whole box. As I said, I have to apply resizing into whole texts, components of the table. Thanks – ozturkib Nov 9 '20 at 8:57
  • Well, then please provide an example code that actually represents the issue you have. Could you add an example that contains such problematic and too long entries? – leandriis Nov 9 '20 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.