Graphics, Figures & TablesReconstructing a table from webpage in Latex

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
asalas77
Posts: 5
Joined: Sat Nov 19, 2016 9:11 pm

Reconstructing a table from webpage in Latex

Post by asalas77 »

Hello.

I need to reconstruct a table/view I've seen online in my latex document.

The table I'm trying to make can be seen here:
https://www.instagram.com/developer/end ... locations/

Image

Could you help me make that? I'm very new to latex and this is way over my capablities. The table should extend to the text width of the document.

The part with code should be formatted as lstlisting, I would also need one additional column in Parameters section. 2nd row is not necessary.
I tried making the entire thing a table, with \multicolumn spaning enitre table where needed, but I can't put a lstlisting inside it, it adds another column to the table. Also I tried to create a horizontal line with \xfill, but doesn't seem to work inside tables.

Here'san example code for the 3rd row:

Code: Select all

\begin{lstlisting}
{
	"authorities": "string",
	"dateOfBirth": "2016-11-19T16:48:15.682Z",
	"description": "string",
	"email": "string",
	"firstName": "string",
	"gender": "string",
	"id": 0,
	"lastActive": "2016-11-19T16:48:15.682Z",
	"lastName": "string",
	"latitude": 0,
	"loginstreak": 0,
	"longitude": 0,
	"noTargetSince": "2016-11-19T16:48:15.683Z",
	"notifications": "string",
	"password": "string",
	"profilePicture": "string",
	"registerDate": "2016-11-19T16:48:15.683Z",
	"score": 0,
	"status": "string",
	"targetDistance": 0,
	"username": "string"
}   \end{lstlisting}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Reconstructing a table from webpage in Latex

Post by Stefan Kottwitz »

Welcome to the forum!

Why a table? Besides the frame around all, the whole thing could consist of
  • headings (customized \subsection or \paragraph) for entries such as "Requirements" and "Parameters"
  • description lists for the parameters, maybe itemize or description lists for requirements
  • listing snippets for code
There are different section. I don't see table cells, not even columns needed.

Stefan
LaTeX.org admin
asalas77
Posts: 5
Joined: Sat Nov 19, 2016 9:11 pm

Reconstructing a table from webpage in Latex

Post by asalas77 »

Does not need to be a table, that's jus the approach I tried, I didn't really know how to begin so just picked up first thing that came to my mind.

Can I have multiple definitions of sections and paragraphs? I'm using a predefined template that I can't make changes to and this component is only a small portion of my document.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Reconstructing a table from webpage in Latex

Post by Stefan Kottwitz »

As it is not numbered, it could be a simple macro for the style of the heading, without numbering or referencing, so kind of a font style and size choice with \MakeUppercase and a line to the right.

Perhaps try putting something together, such as text in lists for the other sections. The more you post here as code, the easier for readers to work on it (copy and paste), so maybe a quicker solution. I would not spend time typing sample text ... and maybe another reader joins here with further suggestions (I'm a bit short on time now).

Stefan
LaTeX.org admin
asalas77
Posts: 5
Joined: Sat Nov 19, 2016 9:11 pm

Reconstructing a table from webpage in Latex

Post by asalas77 »

I tried your way and I almost got it how I want it:

Image


but there's a small white line at the bottom of the box that I can't find. The inner margins of the mdframed are all set to 0.

Also I copied most of this from different places, so I'm not entirely sure how it works, is it possible to make a little more space between the word Parameters and the horizontal line?

Code: Select all

\documentclass[a4paper,onecolumn,oneside,12pt,extrafontsizes]{memoir}
\usepackage[polish]{babel}
\usepackage{tabularx}
\usepackage{color}
\usepackage{tcolorbox}

\usepackage[framemethod=tikz]{mdframed}
\definecolor{mycolor}{rgb}{0.122, 0.435, 0.698}
\definecolor{bluefont}{HTML}{447198}
\definecolor{jsonbg}{HTML}{F5F5F5}

\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newmdenv[innerlinewidth=1pt, roundcorner=4pt,linecolor=mycolor,innerleftmargin=0pt,
innerrightmargin=0pt,innertopmargin=0pt,innerbottommargin=0pt]{mybox}


\def\Vhrulefill{\leavevmode\leaders\hrule height 0.7ex depth \dimexpr0.4pt-0.7ex\hfill\kern0pt}


\begin{document}

\begin{mybox}
\renewcommand{\arraystretch}{1.4}
\begin{tabularx}{\textwidth}{C{2.5cm} X} 

 \large{\color{white}\cellcolor{mycolor}\texttt{\textbf{GET}}} & \cellcolor{jsonbg}\texttt{/register/} \\
\hline
\end{tabularx}

\begin{lstlisting}
	{
			"authorities": "string",
			"dateOfBirth": "2016-11-19T16:48:15.682Z",
			"description": "string",
			"email": "string",
			"firstName": "string",
			"gender": "string",
			"id": 0,
			"lastActive": "2016-11-19T16:48:15.682Z",
			"lastName": "string",
			"latitude": 0,
			"loginstreak": 0,
			"longitude": 0,
			"noTargetSince": "2016-11-19T16:48:15.683Z",
			"notifications": "string",
			"password": "string",
			"profilePicture": "string",
			"registerDate": "2016-11-19T16:48:15.683Z",
			"score": 0,
			"status": "string",
			"targetDistance": 0,
			"username": "string"
	}   \end{lstlisting}

%\noindent\rule[0.2ex]{\linewidth}{0.2pt}

\begin{tcolorbox}[arc=0mm,colback=jsonbg,leftrule=0pt,rightrule=0pt,toprule=0.5pt,bottomrule=0pt]

Zwraca informacje o istnieniu konta uzytkownika o zadanej nazwie.

\vspace{\baselineskip}
\color{bluefont}\textsc{Parametry} \Vhrulefill
\color{black}
\begin{description}[leftmargin=1cm]
\item [name] String : nazwa uzykownika
\end{description}

\vspace{\baselineskip}
\end{tcolorbox}
\end{mybox}

\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Reconstructing a table from webpage in Latex

Post by Stefan Kottwitz »

You can remove the white space at the bottom by
  • adding a bit negative margin to my box: innerbottommargin=-3pt
  • making the tcolorbox rounded too, otherwise the rounded corners of my box would overlap with the sharp corners of tcolorbox: \begin{tcolorbox}[arc=4pt, ...]
For some space after "Parametry", simply add \ or \quad or \hspace for some space, such as \textsc{Parametry}\quad\Vhrulefill or \textsc{Parametry}\ \Vhrulefill or \textsc{Parametry}\hspace{1.5ex}\Vhrulefill.

Stefan
LaTeX.org admin
Post Reply