テンプレート:Chapter

提供: wiki
2014年5月20日 (火) 17:29時点におけるwiki>Nazg-gulによる版
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

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