Debian Codegraph @

utils/lacheck/test-def.tex

raw
1 % $Id: test-def.tex 63198 2022-05-01 15:18:17Z karl $
2 % This file is public domain.
3
4 \documentclass{report}
5 \newcommand{\defaultleftmargin}{0.25in}
6 %\setlength{\oddsidemargin}{\defaultleftmargin}
7 %\providecommand{\defaultmargin}{0.25in}\def\defx{\defy}
8
9 % based on report:
10 % Date: Mon, 25 Apr 2022 15:37:27 -0600
11 % From: Michael Clark
12 %
13 \def\ibx{\textit{#1}} % \def with nested braces in rhs
14 \newcommand\ibx{\textit{#1}} % \newcommand\foo
15 \newcommand{\ibx}{\textit{#1}} % \newcommand{\foo}
16 \newcommand{\ibx}{\textbf{\textit{#1}}} % more nesting
17
18 % *-form
19 \newcommand*{\ibxstar}{\textit{#1}}
20
21 % arg count
22 \newcommand{\ibx}[1]{\textit{#1}}
23
24 % optarg default
25 \newcommand{\ibx}[1][dflt]{\textit{#1}}
26
27
28 \begin{document}
29 \end{document}
30
31 % See Makefile.am for rebuild + test recipe.
32
33 % emacs-page
34 % [https://tug.org/pipermail/tex-live/2019-January/043083.html]
35 %
36 % Date: Thu, 24 Jan 2019 19:11:18 -0800
37 % From: Zayd Hammoudeh <[email protected]>
38 % To: <[email protected]>
39 % Subject: [tex-live] Possible lacheck Bug Report
40 %
41 % [...]
42 %
43 % In the simple LaTeX file:
44 % \documentclass{report}
45 %
46 % \newcommand{\defaultleftmargin}{0.25in}
47 %
48 % \begin{document}
49 % \end{document}
50 %
51 % I get the following errors with lacheck:
52 % "hw01.tex", line 5: <- unmatched "end of file hw01.tex"
53 % "hw01.tex", line 2: -> unmatched "{"
54 %
55 % This is reported by Vim's syntastic running lacheck ver. $Id:
56 % lacheck.lex,v 1.26 1998/03/07 07:46:45 abraham Exp $ on MacOS High
57 % Sierra. The issue only seems to arise when \newcommand is followed by
58 % {\def*} (where * is zero or more other characters). Removal of the curly
59 % brackets around \def* or any term other than def causes the issue to go away.
60 %
61 % [...]
62 %
63 % Edit: The issue appears to not be limited to newcommand. I get the same
64 % error for the line:
65 % \setlength{\oddsidemargin}{\defaultleftmargin}
66
67
68 % emacs-page
69 % https://tug.org/pipermail/tex-live/2022-April/048096.html
70 % Date: Mon, 25 Apr 2022 15:37:27 -0600
71 % From: Michael Clark <[email protected]>
72 % To: <[email protected]>
73 % Subject: lacheck is confused when curly brackets are inside a \newcommand
74 %
75 % Example latex file (foo.tex):
76 %
77 % \newcommand{\boldx}[1]{{\bf #1}}
78 % \newcommand{\ibx}[1]{\textbf{\textit{#1}}}
79 %
80 % lacheck output:
81 %
82 % "foo.tex", line 1: <- unmatched "}"
83 % "foo.tex", line 1: -> unmatched "beginning of file foo.tex"
84 % "foo.tex", line 2: <- unmatched "}"
85 % "foo.tex", line 1: -> unmatched "beginning of file foo.tex"
86 %
87 % I pulled the example commands from
88 % https://www.physicsread.com/latex-bold/ showing two useful cases. One,
89 % using a command inside of a newcommand, and the other creates a group
90 % to isolate the scope of the command to the included text.
91 %
92 % Replacing \newcommand with \newcommand* reports no error as expected.
93 % If an error is expected behavior for \newcommand, it would be nice if
94 % the error message were more clear, as the brackets are correctly
95 % matched.
96 %
97 % Thank you for maintaining this tool. I'd need to devote longer than I
98 % have to figure out where to go from line 391 of lacheck.l
99 % (https://tug.org/svn/texlive/trunk/Build/source/utils/lacheck/lacheck.l?view=markup#l391)