![为竞技淘汰赛项目创建表格](https://linux22.com/image/258896/%E4%B8%BA%E7%AB%9E%E6%8A%80%E6%B7%98%E6%B1%B0%E8%B5%9B%E9%A1%B9%E7%9B%AE%E5%88%9B%E5%BB%BA%E8%A1%A8%E6%A0%BC.png)
我以前曾使用 LaTeX 处理过相当大的文档,但从没有用过它处理过图表。
我想创建一个描述淘汰赛运动项目的表格,例如像找到的表格这里在 HTML 中。
我该如何在 LaTeX 中创建这样的东西?也许已经有一个这样的包,但我找不到它。但如果没有,你会建议我学习和结合哪些包?
答案1
您可以使用hvfloat
包;一个小例子:
\documentclass{article}
\usepackage{hvfloat}
\begin{document}
\section{Test Section}
\hvFloat[rotAngle=90,nonFloat]%
{}%
{\begin{tabular}{ll}
column 1a & column 2a \\
column 1b & column 2b \\
column 1c & column 2c \\
\end{tabular}}%
{A rotated table}%
{fig:test}
\end{document}
1:https://i.stack.imgur.com/ls7ba.png你可以使用以下方式生成表格TikZ
及其trees
库;在树内部,\Pair
命令(两列表格)用于填充信息;此命令有四个强制参数:
\Pair{<team1>}{<score>}{<team2>}{<score>}
代码如下:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{trees}
\newcommand\Pair[4]{%
\arrayrulecolor{cyan!60!black!40}%
\arrayrulewidth=1pt
\renewcommand\extrarowheight{1.5pt}%
\begin{tabular}{|p{2cm}|>{\centering\arraybackslash}p{10pt}|}
\hline
\rowcolor{cyan!60!black!10}\textcolor{red!60!black}{#1} & \textcolor{red!60!black}{#2} \\
\hline
\rowcolor{cyan!60!black!10}\textcolor{red!60!black}{#3} & \textcolor{red!60!black}{#4} \\
\hline
\end{tabular}%
}
\begin{document}
\begin{tikzpicture}[
level distance=5cm,every node/.style={minimum width=3cm,inner sep=0pt},
edge from parent/.style={cyan!70!black,ultra thick,draw},
level 1/.style={sibling distance=4cm},
level 2/.style={sibling distance=2cm},
legend/.style={draw=orange,fill=orange!30,inner sep=3pt}
]
\node (1) {\Pair{Netherlands}{0}{Spain}{1}}
[edge from parent fork left,grow=left]
child {node (2) {\Pair{Netherlands}{4}{Uruguay}{2}}
child {node (3) {\Pair{Germany}{2}{Colombia}{1}}}
child {node {\Pair{Russia}{0}{Spain}{2}}}
}
child {node {\Pair{Germany}{0}{Spain}{1}}
child {node {\Pair{Germany}{2}{Colombia}{1}}}
child {node {\Pair{Russia}{0}{Spain}{2}}}
};
\node[legend] at ([yshift=50pt]3) (QF) {Quarter Finals};
\node[legend] at (2|-QF) {Semi-Finals};
\node[legend] at (1|-QF) (QF) {Final};
\end{tikzpicture}
\end{document}
答案2
一些可以帮助您入门的东西。
\documentclass{standalone}
\usepackage{tikz-qtree}
\begin{document}
\begin{tikzpicture}%
[ every text node part/.style={draw, align = left, inner sep = 0pt} ]
% Setup for horizontal tree
% Grow tree to right with nodes placed clockwise(')
\tikzset{grow'=left}
% Use edges with 90° bends instead of default straight
\tikzset{edge from parent/.style = { draw,
edge from parent path = { (\tikzparentnode.west)
-- +(-8pt, 0)
|- (\tikzchildnode.east) }}}
% Increase horizontal spacing (adjust if length of name is long)
\tikzset{level distance = 6em}
% Adjust the alignment of the nodes
\tikzset{every tree node/.style = {draw, anchor = base west}}
\Tree[ .{Team 1}
[ .{Team 1} {Team 2}
[.{Team 1} {Team 3} {Team 4} ] ]
[.{Team 5} {Team 5} {Team 6} ] ]
\end{tikzpicture}
\end{document}
结果:
您可以进一步编辑树,以便每个节点都是一个表。以更好地匹配您链接到的表。