天天看點

[Latex]生成Vertical Timeline

Vertical TimeLine

用Latex生成一個豎直的VerticalTimeline的想法來源于今天翻看王老師的教師寄語,有感于學院走過的作業系統實驗的艱辛之路,遂産生了寫一個“小作業系統實驗大事記”的想法。

一開始是打算用橫版的TimeLine,但是後來在何某濤的建議下選擇了豎版的TimeLine,記錄經驗供以後參考。

此文主要内容出自:http://tex.stackexchange.com/questions/196794/how-can-you-create-a-vertical-timeline

(感謝StackOverFlow的衆多平凡而又偉大的專家為程式員們做出的無私奉獻)

\documentclass[a4paper, twoside, 11pt]{report}

\usepackage[utf8]{inputenc}
\usepackage[TS1,T1]{fontenc}
\usepackage{fourier, heuristica}
\usepackage{array, booktabs}
\usepackage{graphicx}
\usepackage[x11names]{xcolor}
\usepackage{colortbl}
\usepackage{caption}
\DeclareCaptionFont{blue}{\color{LightSteelBlue3}}

\newcommand{\foo}{\color{LightSteelBlue3}\makebox[0pt]{\textbullet}\hskip-0.5pt\vrule width 1pt\hspace{\labelsep}}

\begin{document}

\begin{table}
\renewcommand\arraystretch{1.4}\arrayrulecolor{LightSteelBlue3}
\captionsetup{singlelinecheck=false, font=blue, labelfont=sc, labelsep=quad}
\caption{Timeline}\vskip -1.5ex
\begin{tabular}{@{\,}r <{\hskip 2pt} !{\foo} >{\raggedright\arraybackslash}p{5cm}}
\toprule
\addlinespace[1.5ex]
1947 & AT and T Bell Labs develop the idea of cellular phones\\
1968 & Xerox Palo Alto Research Centre envisage the 'Dynabook\\
1971 & Busicom 'Handy-LE' Calculator\\
1973 & First mobile handset invented by Martin Cooper\\
1978 & Parker Bros. Merlin Computer Toy\\
1981 & Osborne 1 Portable Computer\\
1982 & Grid Compass 1100 Clamshell Laptop\\
1983 & TRS-80 Model 100 Portable PC\\
1984 & Psion Organiser Handheld Computer\\
1991 & Psion Series 3 Minicomputer\\
\end{tabular}
\end{table}
\end{document} 
           

這是我最後敲定的一個latex模版,它樣子還是非常漂亮的。它是基于table改造而成的,我又将它略微改造,加進了我們的《小作業系統實驗指導書》裡。

效果圖如下:

[Latex]生成Vertical Timeline

略微改過的TimeLine

首先把以下部分加入導言區

\usepackage[utf8]{inputenc}
\usepackage[TS1,T1]{fontenc}
\usepackage{array, booktabs}
\usepackage{graphicx}
\usepackage[x11names]{xcolor}
\usepackage{colortbl}
\usepackage{caption}
\definecolor{baseD}{HTML}{7CAFC2}
%baseD是一個很柔和的藍色,你可以在相關github首頁找到base16色的圖樣。
\newcommand{\foo}{\color{baseD}\makebox[0pt]{\textbullet}\hskip-0.5pt\vrule width 1pt\hspace{\labelsep}}
           

把這些加入導言區後(如果你正常安裝了texlive-full的話一般是不會提示需要安裝額外的sty檔案),想在某個地方插入這個“大事記”表的話就直接插入如下代碼即可

\begin{table}
\centering
%大事表居中顯示
\renewcommand\arraystretch{1.4}\arrayrulecolor{baseD}
\captionsetup{singlelinecheck=false, labelfont=sc, labelsep=quad}
\caption{Timeline}\vskip -1.5ex
%vskip是标題到下面的表格的距離
\begin{tabular}{@{\,}r <{\hskip 2pt} !{\foo} >{\raggedright\arraybackslash}p{5cm}}
%5cm這個參數是指表的總的寬度,如果想做得大一點就把5cm調整放大一點。
\toprule
\addlinespace[1.5ex]
%這個是表格的行距
1947 & AT and T Bell Labs develop the idea of cellular phones\\
1968 & Xerox Palo Alto Research Centre envisage the 'Dynabook\\
1971 & Busicom 'Handy-LE' Calculator\\
%加入的格式為 年份 & 事件 \\(用來換行)
\end{tabular}
\end{table}
           

後來發現這樣的表會帶上

Table x.x Timeline

的标簽,我比較讨厭

Table

的标簽,是以把

\caption{Timeline}

使用

\caption*{Timeline}

替換即可做到無表标号的效果。