@@ -68,6 +68,7 @@ func resolveInputs(mainLatexPath string, basePath string) (string, error) {
68
68
commands := []string {
69
69
`\input` ,
70
70
`\include` ,
71
+ `\usepackage` ,
71
72
}
72
73
73
74
// replace the command with actual file content
@@ -88,11 +89,23 @@ func resolveInputs(mainLatexPath string, basePath string) (string, error) {
88
89
// read path in the brace
89
90
path := source [startIndex + len (com ) : endIndex - 1 ]
90
91
if filepath .Ext (path ) == "" {
91
- path = path + ".tex"
92
+ if strings .Contains (com , `\usepackage` ) {
93
+ path = path + ".sty"
94
+ } else {
95
+ path = path + ".tex"
96
+ }
97
+ }
98
+
99
+ path = filepath .Join (basePath , path )
100
+
101
+ if _ , err := os .Stat (path ); os .IsNotExist (err ) {
102
+ // remove the command
103
+ source = source [:startIndex ] + source [endIndex :]
104
+ continue
92
105
}
93
106
94
107
// read file content
95
- _source , err := readFile (filepath . Join ( basePath , path ) )
108
+ _source , err := readFile (path )
96
109
if err != nil {
97
110
return "" , err
98
111
}
@@ -184,6 +197,10 @@ func (paper *Paper) readLatexSource(path string) error {
184
197
}
185
198
macros := []Macro {}
186
199
for _ , str := range macroStrs {
200
+ if strings .Contains (str , "@" ) {
201
+ continue
202
+ }
203
+ // extract command part, ex) \def\bm... -> \bm
187
204
s := 3 + strings .Index (str [3 :], `\` )
188
205
e := len (str )
189
206
for _ , c := range []string {` ` , `}` , `{` , `[` } {
0 commit comments