6

How do I make this table?

In stackexchange, if you type ">" at the first of the sentence, you get the above quotation.

I tried to do the same thing on LaTeX, but it did not work.

How do I make that?

6
  • Welcome to TeX SX! Which table?
    – Bernard
    Commented Apr 11, 2016 at 21:36
  • What is the question here? Do mean $<$ ? Or is it the missing \usepackage[T1]{fontenc} problem, resulting in strange output from < when used in text mode?
    – user31729
    Commented Apr 11, 2016 at 21:37
  • 5
    in your title you use < but in the question you use > but I think you do not want either you want a quotation such as \begin{quote}....\end{quote} the markdown syntax for a quote is > at the beginning of a line but there is essentially no similarity between markdown and latex Commented Apr 11, 2016 at 21:40
  • the ">" character results in a blockquote on SX not a table.
    – naphaneal
    Commented Apr 11, 2016 at 21:49
  • I tried to do the same thing on LaTeX, and where is your code? You should always post what you have tried even if it fails. In this way you can get an explanation of why it fails. Moreover give me teh codez questions aren't usually well regarded when the author puts no effort in them.
    – Bakuriu
    Commented Apr 12, 2016 at 7:04

3 Answers 3

10
\documentclass{article}

\makeatletter
\renewenvironment{quote}{%
  \vskip 10\p@
  \parindent\z@
  \d@ublerule
  \list{}{\rightmargin\leftmargin}%
  \item\relax
}{%
  \endlist
  \d@ublerule
}
\def\d@ublerule{\hrule\@width\hsize\kern 1.5\p@\hrule\@width\hsize}
\makeatother

\begin{document}
\begin{quote}
  How do I make this table?
\end{quote}
\end{document}

output1_quote

Addendum

If the background should be colored you can use the tcolorbox package:

\renewenvironment{quote}{%
  \vskip 10\p@
  \parindent\z@
  \tcolorbox[
    sharp corners,
    boxrule=\z@,
    boxsep=\z@,
    left=\z@,
    right=\z@,
    top=\z@,
    bottom=\z@
  ]
  \d@ublerule
  \vskip 5\p@
  \list{}{\rightmargin\leftmargin}%
  \item\relax
}{%
  \endlist
  \d@ublerule
  \endtcolorbox
}

output2

The final version could then be:

\documentclass{article}
\usepackage{xcolor}
  \definecolor{sx-yellow}{RGB}{249,245,233}
  \definecolor{sx-orange}{RGB}{224,215,188}
\usepackage[most]{tcolorbox}

\makeatletter
\renewenvironment{quote}{%
  \vskip 10\p@
  \parindent\z@
  \tcolorbox[
    breakable, sharp corners,
    boxrule=\z@, boxsep=\z@,
    left=\z@, right=\z@,
    top=\z@, bottom=\z@,
    colback=sx-yellow
  ]
  {\color{sx-orange}\d@ublerule}
  \vskip 5\p@
  \list{}{\rightmargin\leftmargin}%
  \item\relax
}{%
  \endlist
  {\color{sx-orange}\d@ublerule}
  \endtcolorbox
  \vskip 5\p@
}
\def\d@ublerule{\hrule\@width\hsize\kern 1.5\p@\hrule\@width\hsize}
\makeatother

\begin{document}
\begin{quote}
  How do I make this table?
\end{quote}
\end{document}

output3

output_final

7
  • Your final version imho doesn't look very good before and after a page break.
    – Benjamin
    Commented Apr 12, 2016 at 0:04
  • @Benjamin, I tested the final patch with sorrounding text forcing a page break. i.e. \lipsum[1-n]\begin{quote} How do I make this table? \end{quote}\lipsum and I can't really see what you possibly mean. Can you explain a little bit further what does not look good in your opinion?
    – Ruben
    Commented Apr 12, 2016 at 0:14
  • What I mean is something like this \begin{quote}\lipsum[1-5]\end{quote}. So that the page break is inside the quote environment.
    – Benjamin
    Commented Apr 12, 2016 at 0:19
  • @Benjamin -- ok, this explains the circumstances but not the actual "misbehaviour". Anyways, I compiled your example to infer your esthetics about colored boxes spaning multiple pages and I guess you mean the padding of the borders facing the page. That is imho a prety marginal detail, not to say irrelevant. If someone likes a slight padding better he can just use your solution, or not?
    – Ruben
    Commented Apr 12, 2016 at 0:31
  • Yes, I mean the padding at the beginning and end of a page. It is a matter of taste, sure. But I like my padding. ;)
    – Benjamin
    Commented Apr 12, 2016 at 0:38
3

Try

\begin{tabular}{c}
    \hline put your words here \\
    \hline
\end{tabular}

This gives you

3

Another possibility would be to solely use the package tcolorbox and define a custom environment with it. If it is not a requirement to redefine quote environment, this solution is imho easier to read and adjust than @Ruben's solution. Apart from that it introduces a small padding at the beginning and end when the box is too big, that a page break is necessary. Have a look at the second screenshot to get an idea what that will look like.

\documentclass{article}

\usepackage[most]{tcolorbox}
\definecolor{background}{HTML}{F9F5E9}
\definecolor{linecolor}{HTML}{E0D7BC}
\newtcolorbox{QuoteBox}{%
  breakable,
  enhanced,
  sharp corners,
  colback=background,
  colframe=background,
  borderline north={0.5pt}{0pt}{linecolor},
  borderline north={0.5pt}{1.5pt}{linecolor},
  borderline south={0.5pt}{0pt}{linecolor},
  borderline south={0.5pt}{1.5pt}{linecolor},
}

\begin{document}

\begin{QuoteBox}
How do I make this table?
\end{QuoteBox}

\end{document}

OUTPUT:

tcolorbox tcolorbox_2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .