0

I'm trying to format a table that is about 3/4 the width of the paragraph text. I tried using tabular to do this, however it has some problems. First, the default table extends past my documents margins. Second, there is too much spacing in the table and it is too wide.

Does anyone know how to control the width so it's about 3/4 the width of the paragraph? Also, how to emphasize / italicize the entire table?

Thanks!

enter image description here

\documentclass[letterpaper]{ltxdoc}
\usepackage[left=3cm, right=3cm]{geometry}
\usepackage{lipsum}
\setlength{\parskip}{1em}
\usepackage[T1]{fontenc}

\begin{document}

\lipsum
\begin{center}
  \begin{tabular}{ c c c c c }
    <ARGUMENT> & $\equiv$ & <PROP\_PREMISE\_MAJOR> & <PROP\_PREMISE\_MINOR> & <PROP\_CONCL>
  \end{tabular}
\end{center}

\end{document}
Nick
  • 143
  • 1
    Welcome to TeX.SE! Please one problem per questio :-). For the first try to use tabular environment. If you will provide complete small, compilable document with your problem, than is the most likely that you will get answer soon. – Zarko May 28 '19 at 18:17
  • Hi thanks. I tried tabular, however the results are still off. It may have to do with the margins? – Nick May 28 '19 at 23:51

3 Answers3

1

Here is a solution using the listings package (based on https://tex.stackexchange.com/a/149718/189932):

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{listings}% http://ctan.org/pkg/listings
\lstset{
  basicstyle=\ttfamily,
  mathescape
}
\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sit amet convallis tortor. Etiam consequat diam in iaculis sagittis. Praesent vel scelerisque ex.
\begin{lstlisting}
  <ARGUMENT> $\equiv$ <PROP_PREMISE1> <PROP_PREMISE2> <PROP_CONCL>
  <ARGUMENT> $\equiv$ <PROP_PREMISE2> <PROP_PREMISE1> <PROP_CONCL>
\end{lstlisting}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sit amet convallis tortor. Etiam consequat diam in iaculis sagittis. Praesent vel scelerisque ex.
\begin{lstlisting}
  class Stack {
        char* v;
        int top;
        int max_size;
  public:
\end{lstlisting}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sit amet convallis tortor. Etiam consequat diam in iaculis sagittis. Praesent vel scelerisque ex.

\end{document}

Output: enter image description here

EDIT: The question has changed considerably since this answer was posted, so this answer may no longer be relevant.

daneel
  • 111
  • Thanks! I'm trying the tabular solution. I tried listings, however could not get the entire listing to emphasize in italics, only key words. – Nick May 28 '19 at 23:52
1

You can use tabulary, but 0.75 linewidth is to narrow for your five columns. You have to break the words, reduce the fontsize or increase the table lenght (or a combination):

\documentclass[letterpaper]{ltxdoc}
\usepackage[left=3cm, right=3cm]{geometry}
\usepackage{lipsum, tabulary}
\setlength{\parskip}{1em}
\usepackage[T1]{fontenc}

\begin{document}

\lipsum
\begin{center}
  \begin{tabulary}{0.75\linewidth}{CCCCC}
    <ARGUMENT> & $\equiv$ & <PROP\ \_PREMISE\ \_MAJOR> & <PROP\ \_PREMISE\ \_MINOR> & <PROP\ \_CONCL>
  \end{tabulary}
\end{center}

\end{document}

enter image description here

With \footnotesizeand wider tabular:

\documentclass[letterpaper]{ltxdoc}
\usepackage[left=3cm, right=3cm]{geometry}
\usepackage{lipsum, tabulary}
\setlength{\parskip}{1em}
\usepackage[T1]{fontenc}

\begin{document}

\lipsum

{\centering\footnotesize %put the table in a group
\begin{tabulary}{\linewidth}{@{}CCCCC@{}}
    <ARGUMENT> & $\equiv$ & <PROP\_PREMISE\_MAJOR> & <PROP\_PREMISE\_MINOR> & <PROP\_CONCL>
  \end{tabulary}
\end{center}
}

\end{document}

enter image description here

Sveinung
  • 20,355
0

Your table is wider than text. Try reduce font size to \small and \tabcolsep size to 2pt:

\documentclass[letterpaper]{ltxdoc}
\usepackage[left=3cm, right=3cm]{geometry}
\setlength{\parskip}{1em}
\usepackage[T1]{fontenc}

\usepackage{lipsum}

\begin{document}
\lipsum[1]
\begin{center}
\small
\setlength\tabcolsep{2pt}
  \begin{tabular}{@{} c c c c c @{}}
    <ARGUMENT> & $\equiv$ & <PROP\_PREMISE\_MAJOR> & <PROP\_PREMISE\_MINOR> & <PROP\_CONCL>
  \end{tabular}
\end{center}
\end{document}

enter image description here

However, you change your original question a lot, so the first answer, which contain solution for your original question, is not related to edited anymore. It would be better that you would ask new question ...

Zarko
  • 296,517