tabularxを含むマクロが動作しない

tabularxを含むマクロが動作しない

- living dead の投稿
返信数: 2
下記のようなソースをコンパイルしようとしているのですが,後述するようなエラーが出て止まってしまいます.

\documentclass[a4j, 11pt, report]{jsbook}
\pagestyle{empty}
\usepackage{ascmac}
\usepackage[dvipdfmx]{graphicx}
\graphicspath{{../images/}}
\西暦
\usepackage{url}
\usepackage{plext}
\usepackage{natbib}
\bibpunct[:]{(}{)}{;}{a}{}{;}
\usepackage[at]{easylist}
\usepackage{subcaption}
\usepackage[T1]{fontenc}
\usepackage{txfonts}
\usepackage{tabularx}

\newcounter{excerpt}
\setcounter{excerpt}{0}
\newcounter{lnum}
\newcommand{\lnum}[0]{\refstepcounter{lnum}\texttt{\thelnum}}
\newcolumntype{R}{>{\raggedright\arraybackslash}X}
\newenvironment{excerpt}[2]{%
\setcounter{lnum}{0}
\begin{table}[htbp]
\small
\refstepcounter{excerpt}
\textgt{データ\theexcerpt }#1\\
\label{data:#2}
\begin{tabularx}{\linewidth}{llX}}{%
\end{tabularx}
\end{table}
}

\begin{document}

\begin{excerpt}{テスト}{test}
\lnum & B: & ほげほげ\\
\lnum & C: & ふがふが\\
\lnum & B: & ぴよぴよ\\
\end{excerpt}

\end{document}

以下エラー:

Call `platex test_bg.tex'
This is e-pTeX, Version 3.14159265-p3.7-160201-2.6 (utf8.euc) (TeX Live 2016) (preloaded format=platex)
restricted \write18 enabled.
entering extended mode
(./test_bg.tex
pLaTeX2e <2016/09/08> (based on LaTeX2e <2016/03/31> patch level 3)
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/platex/jsclasses/jsbook.cls
Document Class: jsbook 2016/09/08 okumura, texjporg
(/usr/local/texlive/2016/texmf-dist/tex/platex/jsclasses/jslogo.sty))
(/usr/local/texlive/2016/texmf-dist/tex/platex/base/ascmac.sty
(/usr/local/texlive/2016/texmf-dist/tex/platex/base/tascmac.sty))
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics-def/dvipdfmx.def)))
(/usr/local/texlive/2016/texmf-dist/tex/latex/url/url.sty)
(/usr/local/texlive/2016/texmf-dist/tex/platex/base/plext.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/natbib/natbib.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/easylist/easylist.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/caption/subcaption.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/caption/caption.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/caption/caption3.sty)

Package caption Warning: Unsupported document class (or package) detected,
(caption) usage of the caption package is not recommended.
See the caption package documentation for explanation.

)) (/usr/local/texlive/2016/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/t1enc.def))
(/usr/local/texlive/2016/texmf-dist/tex/latex/txfonts/txfonts.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/tools/tabularx.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/tools/array.sty)) (./test_bg.aux)
(/usr/local/texlive/2016/texmf-dist/tex/latex/txfonts/omltxmi.fd)
(/usr/local/texlive/2016/texmf-dist/tex/latex/txfonts/omstxsy.fd)
(/usr/local/texlive/2016/texmf-dist/tex/latex/txfonts/omxtxex.fd)
(/usr/local/texlive/2016/texmf-dist/tex/latex/txfonts/utxexa.fd)
(I search kanjifont definition file: . . ) (I search font definition file: . .
. . . . . ) (/usr/local/texlive/2016/texmf-dist/tex/latex/txfonts/t1txr.fd))
Runaway argument?
! File ended while scanning use of \TX@get@body.
<inserted text>
\par
<*> test_bg.tex
 
?

! File ended while scanning use of \TX@get@body.
というエラーですので,なにか単純な制御文字の抜けがあるのだと思うのですが,発見できません.
どうぞお力をお借りできますと幸いです.

living dead への返信

Re: tabularxを含むマクロが動作しない

- 前田 一貴 の投稿
https://qiita.com/krtx/items/9204418fc507a311548d
https://tex.stackexchange.com/questions/42325/tabularx-inside-a-newenvironment

excerpt 環境の定義を次のように変えてください.

\newenvironment{excerpt}[2]{%
\setcounter{lnum}{0}
\table[htbp]
\small
\refstepcounter{excerpt}
\textgt{データ\theexcerpt }#1\\
\label{data:#2}
\tabularx{\linewidth}{llX}}{%
\endtabularx
\endtable
}
前田 一貴 への返信

Re: tabularxを含むマクロが動作しない

- living dead の投稿
ご回答ありがとうございます.
無事解決しました.
ドキュメントを読まずに質問いたしまして申し訳ありませんでした.