「テンプレート:Chapter」の版間の差分
(相違点なし)
|
2014年5月20日 (火) 17:29時点における版
Chapter doc
Default case (frontpage)
In python, for readability.
Human algorithm
if l<h: if h-l>=section: col1 else: if h-l+2>=section col1 else: if h-l >2: spezza else: col2 else: col2
Real algorithm
half=({1}[pages]+sections)/2 # sections title have to be taken in account too gap=2 lines=0 columns1={} columns2={} for numsection, section in enumerate({1}): if half-lines+gap>=section[pages]: column1[numsection] = section else: if half-lines>gap: tmp1 = section tmp2 = section tmp1[continues] = 1 tmp2[continued] = 1 for index, page in enumerate(section): if lines + index <= half: del tmp2[index] else: del tmp1[index] column1[numsection] = tmp1 column2[numsection] = tmp2 else: column2[numsection] = section lines += section[pages]+1 # section title itself adds 1 line