1

I want to display my content like in image. I have considered array for this. Let me know if is there any better option for this.

\textbf {accesslog : } \textcolor{red}{ Array } 

   \begin{tabular}{ | l  c  r }

    date: & string & Data - da ocorrência. \\
    ObjectId: & Usuário - & que executou. \\
    action: & String - & Ação Executada.  \\ \\

    date: & string & Data - da ocorrência. \\
    ObjectId: & Usuário - & que executou. \\
    action: & String - & Ação Executada

    \end{tabular}

Currently it looks as here : https://www.sharelatex.com/project/53915feaeef2f99941486f56?r=380e068e&rs=ps&rm=d

Content should look like:

array

IS there any other possible way to show content like this?

4
  • 1
    You can nest tabular environments, so you could put the "access_log" text in one column and the existing tabular in a second column to get the effect you want.
    – Thruston
    Commented Jun 8, 2014 at 8:27
  • @Thruston: yes, wipet's answer cleared this doubt. Are you saying the same as what wipet implemented? his answer is almost done, just issue is with access_log and array text
    – cyclic
    Commented Jun 8, 2014 at 9:26
  • If you want the tall left braces then @wipet has the right approach. But you could put what he has shown you into a tabular to get the other text at the front.
    – Thruston
    Commented Jun 8, 2014 at 10:25
  • @Thruston: I created my doc with some change, here if you can help tex.stackexchange.com/questions/183784/…
    – cyclic
    Commented Jun 8, 2014 at 10:38

2 Answers 2

2

May be you needn't any tabular, if I see the picture well.

\documentclass{article}
\usepackage{color}
\def\red#1{{\color{red}#1}}
\begin{document}

$$
\left(\vcenter{
  \hbox{$\left\{\
      \vcenter{\parindent=0pt
         \hbox{\textbf{date}: \red{string}  Data -- da ocorrncia.}
         \hbox{\textbf{ObjectId}: \red{Usuário} --  que executou.}
         \hbox{\textbf{action}: \red{String} --  Aço Executada.}
   }\right.$}
   \bigskip
   \hbox{$\left\{\
      \vcenter{\parindent=0pt
         \hbox{\textbf{date}: \red{string}  Data -- da ocorrncia.}
         \hbox{\textbf{ObjectId}: \red{Usuário} --  que executou.}
         \hbox{\textbf{action}: \red{String} --  Aço Executada.}
   }\right.$}
}\right.
$$

\end{document}
3
  • thanks a lot, I guess almost solved. In my code I put access_log and array in same line as matrix. But why the content way not inline? When I added access_log and array next to your code, it is also appearing one line up the box
    – cyclic
    Commented Jun 8, 2014 at 9:24
  • 1
    The adding the text before was a little exercise for you :). IMHO tex.stackexchange shares ideas and not primarly serves as a code generator: user sends picture and waits to the code without thinking. I was waiting for pure LaTeX solution here with many \begin{minipage}, \end{minipage}, \begin{array}, \end{array} etc. But such solution didn't arise here.
    – wipet
    Commented Jun 8, 2014 at 10:00
  • I created my doc with some change, here if you can help tex.stackexchange.com/questions/183784/…
    – cyclic
    Commented Jun 8, 2014 at 10:39
2

Here is a LaTeX solution, using the blkarray package. As you seem to declare programming variables and their type, I defined a \variable command, that takes as single argument the variable name and its type, separated by a colon, so as to have a syntax a close as possible from natural writing. It types the whole as you require (variable name in boldface, type in red), and if you forget the type, it types only the variable name. It requires the xparse package.

If you prefer a traditional syntax, the preamble contains another (commented) definition of \variable with 2 arguments.

\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage[a4paper, total={6in, 8in}]{geometry}

\setlength\parindent{0pt}
\usepackage[x11names]{xcolor}
\usepackage{array}
\usepackage{mathtools}

\usepackage{blkarray}
\usepackage{xparse}

%\newcommand*\variable[2]{\textbf{#1} : \textcolor{red}{#2}}

\NewDocumentCommand{\variable}{>{\SplitArgument{1}{:}}m}
{\varargsaux#1}
\NewDocumentCommand{\varargsaux}{mm}
{\IfNoValueTF{#2}{\textbf{#1}}{\textbf{#1}{ : }\textcolor{red}{#2}}}

\def\thickvrule{\vrule width 0.9pt}

\begin{document}

\begin{tabular}{ >{\sffamily}c}
\begin{blockarray}{rcl}%
 \begin{block}{>{\mbox{}}r!{\thickvrule}c@{\enspace}\{l}
 \variable{accesslog : Array}
& & \variable{date : string} -- Data da ocorrência. \\
& & \variable{ObjectId : Usuário} -- que executou. \\
 & & \variable{action : String} -- Ação Executada.\\
\end{block}
\begin{block}{>{\mbox{}}r!{\thickvrule}c@{\enspace}\{l}
& & \variable{date : string} -- Data da ocorrência. \\
& & \variable{ObjectId : Usuário} -- que executou. \\
& & \variable{action : String} -- Ação Executada.\\
\end{block}
\end{blockarray}
\end{tabular}

\end{document} 

enter image description here

1

You must log in to answer this question.

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