Example #1
0
    def addList(self,lists,type=1):
        if type == 1:
            items = Itemize()
        if type == 2:
            items = Enumerate()
        if type == 3:
            items = Description()
        for item in lists:
            items.add_item(item)

        self.content.append(items)
Example #2
0
    def add_list(self,lists,type=1):
        '''添加列表

        :param list lists: 列表内容
        :param int type: 列表类型,取值分别为1,2,3
        :return: 无返回值
        '''
        if type == 1:
            items = Itemize()
        if type == 2:
            items = Enumerate()
        if type == 3:
            items = Description()
        for item in lists:
            items.add_item(item)

        self.content.append(items)
Example #3
0
    def fillFilehead(self):
        self.preamble.append(Command('usetikzlibrary','plotmarks'))
        self.preamble.append(Command('singlespacing'))
        self.preamble.append(Command('parindent 0ex'))

    # course configurations
        self.preamble.append(Command('newcommand',Arguments(Command('class'),NoEscape(self.__class__))))
        self.preamble.append(Command('newcommand',Arguments(Command('term'),NoEscape(self.__term__))))
        self.preamble.append(Command('newcommand',Arguments(Command('examnum'),NoEscape(self.__examnum__))))
        self.preamble.append(Command('newcommand',Arguments(Command('examdate'),NoEscape(self.__date__))))
        self.preamble.append(Command('newcommand',Arguments(Command('timelimit'),NoEscape(self.__timelimit__))))

    # document starts
    # some formation setting
        self.append(Command('pagestyle','head'))
        self.append(Command('firstpageheader',Arguments('', '', '')))

    # draw header, from head.head file
        self.append(Command('runningheader',Arguments(Command('class'),NoEscape(r'\examnum\ - Page \thepage\ of \numpages'))))
        self.append(Command('runningheadrule'))

        with self.create(LatexFulsh()) as fulsh:
            with fulsh.create(LatexTabular(arguments=NoEscape(r'p{2.8in} r l'))) as tabs:
                with open('edb_setting/header.cfg','r') as file:
                    header=file.read().split('<__|__>')
                    tabs.append(NoEscape(header[0]))
            fulsh.append(NoEscape(r'\\'))

        self.append(Command('rule',options='1ex',arguments=Arguments(Command('textwidth'),'.1pt')))
        self.append(Command('newcommand',Arguments(Command('boxwidth'),'0.8cm')))

    # draw statemnts, from coverpage.cfg, instructions for students
        with open('edb_setting/coverpage.cfg','r') as file:
            con=file.read()
            content=con.split('<__|__>')

        self.append(NoEscape(content[0]))
        with self.create(MiniPage(width='3.7in',pos='t')) as minipage:
            minipage.append(Command('vspace','0pt'))
            with minipage.create(Itemize()) as items:
                for itemcont in content[1:]:
                    items.add_item(NoEscape(itemcont))

            minipage.append(NoEscape(r'Do not write in the table to the right.'))

    # draw the score table
        self.append(Command('hfill'))
        with self.create(MiniPage(width='2.3in',pos='t')) as minipage:
            minipage.append(Command('vspace','0pt'))
            minipage.append(Command('gradetablestretch','2'))
            minipage.append(Command('vqword','Problem'))
            minipage.append(Command('addpoints'))
            # grade table setting
            gradetablesetting='v'
            # gradetablesetting='v][page'
            minipage.append(Command('gradetable',options=NoEscape(gradetablesetting)))

        self.append(Command('newpage'))
def itemize(contents):
    ret = Itemize()
    for item in contents:
        ret.add_item(item)
    return ret