我有大量数据,但记录较少,字段数量相对较少;为了举个例子,假设我有一个包含 x 千人的数据库,而我只保存了所有人的属性的相对较少的信息:姓名、年龄、3-4 行文本的简短简历等等。
我认为在纸上浏览的最佳布局是这样的
每个矩形都是一个包含所有信息的表格
现在是困难的部分:我完全不知道如何以合理的方式实现这一点;此外,涉及的文本量很少,但考虑到这种布局,所有内容的对齐和比例更为重要,例如,同一行中的所有表格都应将单元格的限制与给定字段占用的最大高度对齐(如图所示)。
您有针对此问题的软件包或解决方案吗?我通常使用 LatexLive 作为 LaTeX 实现。
答案1
可能不是您想要的,但是有一些代码会有所帮助。
\documentclass[a4paper,landscape]{article}
\usepackage{geometry,array,longtable,booktabs}
\newcommand\person[1]{%
\begin{minipage}[t]{.185\textwidth}
\raggedright
#1
\end{minipage}}
\begin{document}
\setlength{\extrarowheight}{5pt}
\begin{longtable}{*{5}{p{.185\textwidth}}}
\toprule\endhead\bottomrule\endfoot
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\person{Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.}
& \person{Jo\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.}
& \person{Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.}
& \person{Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.}
& \person{Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.}
\\
\end{longtable}
\end{document}
答案2
由于 OP 要求使用具有“重排”属性的常规网格布局,我建议使用栅格包的库tcolorbox
。
tcbitemize
它提供了一个类似于 的环境itemize
。每个项目 ( \tcbitem
) 都由 格式化tcolorbox
,并且所有内容都以网格状布局排列。如果\tcbitem
添加或删除一个,所有内容都会流到其适当的位置。
文本内容\tcbitem
是任意的。可以为每个项目使用一个表格。由于 OP 的 MWE 不包含数据,因此我制作了一些由普通文本内容和一些tabularx
表格混合而成的内容。输出按要求底部对齐。我添加了一些边框线和颜色以在视觉上区分项目。
\documentclass[a4paper,landscape]{article}
\usepackage[hmargin=2cm,top=1cm,bottom=2cm]{geometry}
\usepackage{lipsum}
\usepackage{colortbl,tabularx}
\usepackage[skins,raster]{tcolorbox}
\begin{document}
\begin{tcbitemize}[raster columns=5,raster valign=bottom,
enhanced,size=fbox,sharp corners,boxrule=0pt,middle=0pt,
frame hidden,colback=yellow!10,colframe=yellow!50!black,
borderline horizontal={1pt}{0pt}{yellow!50!black},
segmentation style={solid},
flushleft upper,
]
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\end{tcbitemize}
\end{document}
这是第一个解决方案的变体。它将所有项目调整为相同高度,并将内容对齐到顶部:
\documentclass[a4paper,landscape]{article}
\usepackage[hmargin=2cm,top=1cm,bottom=2cm]{geometry}
\usepackage{lipsum}
\usepackage{colortbl,tabularx}
\usepackage[skins,raster]{tcolorbox}
\begin{document}
\begin{tcbitemize}[raster columns=5,raster equal height=rows,
enhanced,size=fbox,sharp corners,boxrule=0pt,middle=0pt,
frame hidden,colback=yellow!10,colframe=yellow!50!black,
borderline horizontal={1pt}{0pt}{yellow!50!black},
segmentation style={solid},
flushleft upper,
]
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\tcbitem
Joe\\ Big Town\\ Engineer\\ Has had a great life, considering.
\tcbitem
Joe\\ Small Town\\ Astrophysicist\\ Fantastic career following crummy childhood.
\tcbitem
Pat\\ Hamlet\\ Cleaner\\ Bit if a nutter, really. Talks to dead people.
\tcbitem
This is a short note about a person named Jim.
\tcbitem
Alex\\ Homeless\\ President of Company\\ One of the dead people Pat talks to.
\tcbitem
Charles Smith (10)
\tcbline
Denis Doe (12)
\tcbitem
Chris\\ Tent City\\ Accountant\\ Dangerous work. Requires specialist safety gear.
\tcbitem
\begin{tabularx}{\linewidth}{XX}
Name & Smith\\\hline
First Name & Charles\\\hline
Age & 12
\end{tabularx}
\end{tcbitemize}
\end{document}
答案3
正如上面的评论中所提到的,您对自己想要的东西只给出了一个非常粗略的描述。
这是另一种方法。我不确定你的意思是什么标记事情;所以,我猜。
\documentclass{article}
\usepackage{xcolor}
\usepackage{etoolbox}
\usepackage{pgfkeys}
\makeatletter
\newbool{mark by name}
\newbool{mark by job}
\def\ae@table@mark@item{}
\def\ae@table@mark@empty{}
\def\ae@table@mark@color{blue}
\pgfkeys{/ae/table/cell/.cd,
person/.code=\ae@capture@person{#1},
mark by/.is choice,
mark by/name/.code={\booltrue{mark by name}},
mark by/job/.code={\booltrue{mark by job}},
mark if/.store in=\ae@table@mark@item,
mark using/.store in=\ae@table@mark@color
}
%% the user interface
%% all other aspects of the interface are through the use of keys.
\newcommand\populatetable[1]{%%
\boolfalse{mark by name}%%
\boolfalse{mark by job}%%
\noindent
\pgfkeys{/ae/table/cell/.cd,#1}}
%% macros to store information on individuals
\def\ae@person@attribute@name{}
\def\ae@person@attribute@address{}
\def\ae@person@attribute@job{}
%% I use ".store in" instead of ".initial" because
%% I find it easier to test using `\ifx` against an expandable macro
\pgfkeys{/ae/person/attributes/.cd,
name/.store in=\ae@person@attribute@name,
address/.store in=\ae@person@attribute@address,
job/.store in=\ae@person@attribute@job,
comments/.initial=,
}
%% get the attribute you desire
%% -- only capable of retrieving "comments"
\def\ae@get#1{\pgfkeys{/ae/person/attributes/#1}}
%% create the person
\def\ae@capture@person#1{%%
\bgroup
\pgfkeys{/ae/person/attributes/.cd,#1}%%
\ae@present@person
\egroup
}
%% macro to present the information about an individual
\def\ae@present@person{%%
\fbox{\begin{minipage}[t]{1in}
\vspace{0pt}%% to avoid funkiness caused by \color
\ae@test@mark{name}%%
\ae@open@mark Name: \ae@person@attribute@name \ae@close@mark \\
\ae@test@mark{job}%%
\ae@open@mark Job: \ae@person@attribute@job \ae@close@mark\\
Comments: \ae@get{comments}
\end{minipage}}\penalty100\relax}
%% test for what is to be marked and set up parameters to carry this out.
%% --- this could be done much better, but for now this will suffice.
\def\ae@test@mark#1{%%
\def\ae@open@mark{}%%
\def\ae@close@mark{}%%
\ifbool{mark by #1}
{%%
\expandafter\ifx\csname ae@person@attribute@#1\endcsname\ae@table@mark@item
\def\ae@open@mark{\bgroup\color{\ae@table@mark@color}}%%
\def\ae@close@mark{\egroup}%%
\else
\fi
}{}}
\makeatother
\begin{document}
\populatetable{%%
mark by=name,
mark if=John,
mark using=red,
person={name=John,
job=baker,
address=downtown},
person={name=Emily,
job=dentist,
address=1030 Appleton Grove},
person={name=Mandy,
job=teacher,
address=2439 Silly Name Road},
person={name=John,
job=baker,
address=downtown},
person={name=Emily,
job=dentist,
address=1030 Appleton Grove},
person={name=Mandy,
job=teacher,
address=2439 Silly Name Road},
person={name=John,
job=baker,
address=downtown},
person={name=Emily,
job=dentist,
address=1030 Appleton Grove},
person={name=Mandy,
job=teacher,
address=2439 Silly Name Road},
}
\end{document}
结果如下: