使用上括號和下括號格式化整行表格

使用上括號和下括號格式化整行表格

我想在乳膠中使用完全相同的格式,請為此提供代碼。

我只能做一個簡單的排,但不能放置上括號和下括號。

 \documentclass{article}

 \begin{document}
     \begin{tabular}{ |c|c| } 
     \hline
     Physical page \# & pageoffset(12 bits) \\
     \hline
    \end{tabular}
 \end{document}

我已經花了幾個小時搜索這個問題,但沒有得到結果。你能告訴我嗎?

提前致謝 :)

影像

答案1

解決方案\psbrace來自pstricks-add

\documentclass[svgnames]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{mathtools}
\usepackage{pstricks-add, auto-pst-pdf}

\begin{document}

\begin{postscript}
  \psset{braceWidth=0.8pt, braceWidthInner=3pt, braceWidthOuter=3pt, nodesep=8pt, linejoin=1}
  \sffamily\everypsbox{\scriptsize}\renewcommand\arraystretch{1.3}
  physical addr. \begin{tabular}{ |c|c| }
  \hline
  Physical page \# \pnode[0pt, 2.6ex]{N1}\pnode[0pt, -1.25ex]{C1}\hspace*{2em}& \pnode[0pt, -1.25ex]{C2}pageoffs\pnode[2pt, 2.6ex]{N2}e\pnode[-2pt, 2.6ex]{N3}t(12 bits) \pnode[2pt, 2.6ex]{N4}\\
  \hline
  \end{tabular}
  \psbrace[rot=-90, nodesepA=-2.6em, nodesepB=-0.4ex](N2)(N1){\bfseries 9 bits set index}%
  \psbrace[rot=-90, nodesepA=-2.4em, nodesepB=-0.4ex](N4)(N3){5 bits line off}
  \psbrace[rot=90, nodesepA=-1.9em, nodesepB=1.7ex](C1)(C2){\bfseries\textcolor{LimeGreen}{color index} (2 bits -> 4 colors)} %
\end{postscript}

\end{document} 

在此輸入影像描述

答案2

我寧願繪製圖像而不是表格:

在此輸入影像描述

\documentclass[tikz,
               border=3mm,
               12pt
               ]{standalone}
\usetikzlibrary{chains,
                decorations.pathreplacing,
                calligraphy,%had to be after lib. decorations.pathreplacing
                fit,
                positioning
                }

\begin{document}
     \begin{tikzpicture}[
 node distance = 0mm,
   start chain = going right,
every node/.style = {align=center},
    box/.style = {minimum width=#1, minimum height=9mm,
                  inner xsep=0pt, outer sep=0mm,
                  font=\large\sffamily, on chain},
BC/.style args = {#1/#2}{% Brace Calligraphic
        decorate,
        decoration={calligraphic brace, amplitude=6pt,
        pre =moveto, pre  length=1pt,
        post=moveto, post length=1pt,
        raise=#1,
              #2},% for mirroring of brace
        very thick,
        pen colour=red
        },
                        ]
\node (n1) [on chain]       {physical addr.};
\node (n2) [box=12em,draw]  {Physical page \#};
\node (n3) [box= 6em]       {\quad pageoffset};
\node (n4) [box= 4em]       {(bits)};
\node[draw, inner sep=0mm, fit=(n3) (n4)] {};
%
\draw[BC=1mm/ ]    
    ([xshift=-3em] n3.north west) 
        to node[above=3mm] {9 bits\\ set index} (n3.north east);
\draw[BC=1mm/ ]
    (n4.north west) 
        to node[above=3mm] {5 bits\\ line off.} (n4.north east);
\draw[BC=1mm/mirror]
    ([xshift=-3em] n3.south west) 
        to node[below=2mm] {\textcolor{teal}{color index}\\ (2 bits $\to$ 4 colors)} 
    (n3.south east);
    \end{tikzpicture}
 \end{document}

相關內容