def init_module(parser, options): parms = parser.parms macros_latex = '' macros_python = [ # the following is for \end{otherlanguage} Macro(parms, '\\babel@skip@space', args='', repl=''), Macro(parms, '\\foreignlanguage', args='OAA', repl=h_foreignlanguage), Macro(parms, '\\selectlanguage', args='A', repl=h_selectlanguage), ] environments = [ Environ(parms, 'otherlanguage', args='A', repl=h_begin_otherlang, add_pars=False, end_func=h_end_otherlang), Environ(parms, 'otherlanguage*', args='A', repl=h_begin_otherlang, add_pars=False, end_func=h_end_otherlang_star), ] inject_tokens = get_language_token(parser.global_latex_options + options) return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments, inject_tokens=inject_tokens)
def init_module(parser, options, position): parms = parser.parms parms.math_text_macros.append('\\text') macros_latex = r""" \newcommand{\eqref}[1]{(0)} \newcommand{\medspace}{\:} \newcommand{\negmedspace}{} \newcommand{\negthickspace}{} \newcommand{\negthinspace}{} \newcommand{\notag}{} \newcommand{\numberwithin}[2]{} \newcommand{\thickspace}{\;} \newcommand{\thinspace}{\,} """ macros_python = [ Macro(parms, '\\DeclareMathOperator', args='*AA'), Macro(parms, '\\substack', args='A', repl=h_substack), ] environments = [ EquEnv(parms, 'align'), EquEnv(parms, 'align*'), EquEnv(parms, 'alignat', args='A'), EquEnv(parms, 'alignat*', args='A'), EquEnv(parms, 'equation'), EquEnv(parms, 'equation*'), EquEnv(parms, 'flalign'), EquEnv(parms, 'flalign*'), EquEnv(parms, 'gather'), EquEnv(parms, 'gather*'), EquEnv(parms, 'multiline'), EquEnv(parms, 'multiline*'), ] inject_tokens = [] # this list of tokens is used as replacement # for '\documentclass...' or '\usepackage...' return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments, inject_tokens=inject_tokens)
def init_module(parser, options, position): parms = parser.parms parms.newcommand_ignore.append(macro_read_sed) macros_latex = r''' \newcommand{\crefname}[3]{} \newcommand{\Crefname}[3]{} ''' macros_python = [ Macro(parms, macro_read_sed, args='A', repl=h_read_sed), Macro(parms, '\\label', args='OA', repl=''), # Define functions which warn the User, whenever cleveref # is used without invoking \YYCleverefInput. These will be overwritten # by invoking \YYCleverefInput. Macro(parms, '\\cref', args='*A', repl=h_cref_warning), Macro(parms, '\\Cref', args='*A', repl=h_cref_warning), Macro(parms, '\\crefrange', args='*AA', repl=h_cref_warning), Macro(parms, '\\Crefrange', args='*AA', repl=h_cref_warning), ] environments = [] # Warn the user, whenever cleveref is used # without the poorman option: inject_tokens = [] if not is_poorman_used(options): inject_tokens = utils.latex_error(parser, msg_poorman_option, position) return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments, inject_tokens=inject_tokens)
def init_module(parser, options, position): parms = parser.parms macros_latex = "" macros_python = [ Macro(parms, '\\xspace', args='', repl=h_xspace), ] environments = [] return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments)
def init_module(parser, options, position): parms = parser.parms macros_latex = '' macros_python = [ Macro(parms, '\\newabbreviation', args='AAA', repl=r'\newacronym{#1}{#2}{#3}'), ] environments = [] return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments)
def init_module(parser, options): parms = parser.parms macros_python = [ # test_macros.py Macro(parms, '\\delim', args='*OA', repl=h_delim), ] environments = [ # test_environments.py Environ(parms, 'comment', repl='', remove=True, add_pars=False), # test_display.py EquEnv(parms, 'flalign', repl=' relation', remove=True), ] return InitModule(macros_python=macros_python, environments=environments)
def init_module(parser, options, position): parms = parser.parms macros_latex = '' macros_python = [ Macro(parms, '\\addbibresource', args='OA', repl=''), Macro(parms, '\\cite', args='*OOA', repl=h_cite), Macro(parms, '\\Cite', args='*OOA', repl=h_cite), Macro(parms, '\\footcite', args='*OOA', repl=h_footcite), Macro(parms, '\\footcitetext', args='*OOA', repl=h_footcite), Macro(parms, '\\parencite', args='*OOA', repl=h_cite), Macro(parms, '\\Parencite', args='*OOA', repl=h_cite), Macro(parms, '\\printbibliography', args='O', repl=''), ] environments = [] return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments)
def init_module(parser, options, position): parms = parser.parms macros_latex = r""" \newcommand{\href}[3][]{#3} \newcommand{\texorpdfstring}[2]{#1} \newcommand{\url}[1]{#1} """ macros_python = [ Macro(parms, '\\ref', args='*A', repl='0'), ] environments = [] return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments)
def init_module(parser, options): parms = parser.parms parms.math_text_macros.append('\\text') macros_latex = r""" \newcommand{\eqref}[1]{(0)} \newcommand{\medspace}{\:} \newcommand{\negmedspace}{} \newcommand{\negthickspace}{} \newcommand{\negthinspace}{} \newcommand{\notag}{} \newcommand{\numberwithin}[2]{} \newcommand{\thickspace}{\;} \newcommand{\thinspace}{\,} """ macros_python = [ Macro(parms, '\\DeclareMathOperator', args='*AA'), ] environments = [ EquEnv(parms, 'align'), EquEnv(parms, 'align*'), EquEnv(parms, 'alignat', args='A'), EquEnv(parms, 'alignat*', args='A'), EquEnv(parms, 'equation'), EquEnv(parms, 'equation*'), EquEnv(parms, 'flalign'), EquEnv(parms, 'flalign*'), EquEnv(parms, 'gather'), EquEnv(parms, 'gather*'), EquEnv(parms, 'multiline'), EquEnv(parms, 'multiline*'), ] return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments)
def init_module(parser, options): parms = parser.parms macros_latex = r""" \newcommand{\color}[2][]{} \newcommand{\colorbox}[3][]{#3} \newcommand{\definecolor}[4][]{} \newcommand{\textcolor}[3][]{#3} """ macros_python = [ Macro(parms, '\\fcolorbox', args='OAOAA', repl='#5'), ] environments = [] return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments)
def init_module(parser, options, position): parms = parser.parms math_operators = [ '≤', '≥', '→', '∩', '∪', '⇒', '⇐', '⇔', '⊂', ] parms.math_operators.extend(math_operators) macros_latex = r""" \newcommand{\unimathsetup}[1]{} """ macros_python = [ Macro(parms, '\\setmathfont', args='AO', repl='') ] environments = [] return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments)
def init_module(parser, options): parms = parser.parms macros_latex = '' macros_python = [ Macro(parms, '\\gls', args='OA', repl=h_gls('text', [])), Macro(parms, '\\glspl', args='OA', repl=h_gls('plural', [])), Macro(parms, '\\Gls', args='OA', repl=h_gls('text', [cap_first])), Macro(parms, '\\Glspl', args='OA', repl=h_gls('plural', [cap_first])), Macro(parms, '\\GLS', args='OA', repl=h_gls('text', [cap_all])), Macro(parms, '\\GLSpl', args='OA', repl=h_gls('plural', [cap_all])), Macro(parms, '\\glsdesc', args='OA', repl=h_gls('description', [])), Macro(parms, '\\Glsdesc', args='OA', repl=h_gls('description', [cap_first])), Macro(parms, '\\GLSdesc', args='OA', repl=h_gls('description', [cap_all])), Macro(parms, '\\glsdisp', args='OAA', repl='#3'), Macro(parms, '\\glslink', args='OAA', repl='#3'), Macro(parms, '\\glstext', args='OA', repl=h_gls('text', [])), Macro(parms, '\\Glstext', args='OA', repl=h_gls('text', [cap_first])), Macro(parms, '\\GLStext', args='OA', repl=h_gls('text', [cap_all])), Macro(parms, '\\longnewglossaryentry', args='AAA', repl=h_newacronym), Macro(parms, '\\newacronym', args='AAA', repl=h_newacronym), Macro(parms, '\\newglossaryentry', args='AA', repl=h_newglossaryentry), # this is for reading the .glsdefs database Macro(parms, '\\gls@defglossaryentry', args='AA', repl=h_parse_glsdefs), ] environments = [] return InitModule(macros_latex=macros_latex, macros_python=macros_python, environments=environments)
def h_read_sed(parser, buf, mac, args, delim, pos): if not parser.read_macros: return [] # Read sed file into sed: file = parser.get_text_expanded(args[0]) ok, sed = parser.read_macros(file) # Throw LaTeX error if the file could not be loaded: if not ok: return utils.latex_error(parser, 'could not read file ' + repr(file), pos) refs = { '\\cref': { '': {}, '*': {} }, '\\Cref': { '': {}, '*': {} }, '\\crefrange': { '': {}, '*': {} }, '\\Crefrange': { '': {}, '*': {} } } for rep in sed.split('\n'): # only consider non-empty lines: if rep == '': continue # Match \cref,\cref*,\Cref and \Cref* and save the replacement string: m = re_ref.match(rep) if m: refs[m.group(1)][m.group(2)][unescape_sed(m.group(3))] \ = unescape_sed(m.group(4)) continue # Match \crefrange, \crefrange*, \Crefrange and \Crefrange* and # save the replacement string: m = re_ref_range.match(rep) if m: key = (unescape_sed(m.group(3)), unescape_sed(m.group(4))) refs[m.group(1)][m.group(2)][key] \ = unescape_sed(m.group(5)) # Match any other command and create Macro objects for them. # See definition of re_command for more details: m = re_command.match(rep) if m: args = 'A' * int((m.end(3) - m.start(3)) / 4) string = unescape_sed(m.group(4)) if m.group(2): name = re_cC.sub('c', m.group(1)) parser.the_macros[name] = Macro(parser.parms, name, args=args, repl=string) name = re_cC.sub('C', m.group(1)) parser.the_macros[name] = Macro(parser.parms, name, args=args, repl=string) else: name = m.group(1) parser.the_macros[name] = Macro(parser.parms, name, args=args, repl=string) # Make the \cref, …, \Crefrange* Macro objects: for ref in ['\\cref', '\\Cref']: parser.the_macros[ref] = Macro(parser.parms, ref, args='*A', repl=h_make_cref(refs[ref])) for ref in ['\\crefrange', '\\Crefrange']: parser.the_macros[ref] = Macro(parser.parms, ref, args='*AA', repl=h_make_crefrange(refs[ref])) # \YYCleverefInput should not produce any output: return []