質問用フォーラムです。ご質問の前に質問のしかたをご覧ください。

\newenvironment 中の filecontents のファイル名の指定

- Beginner Beginner の投稿
環境の中身を別ファイルに書き出したいと思い、以下のようなコードを書いたのですが、期待通りに動きません。
以下で \input{\filename} を入れなければコンパイルはできますが、当然なにも表示されません。
\input{\filename} を入れると、ファイルは作成されるものの、コンパイルができません。
(TeXLive 2019 の pdflatex を使用しています。)

より具体的には、

./output/q-hoge-fuga.tex が無い状態で実行すると、

LaTeX Warning: Writing file `././output/q-hoge-fuga.tex'.

(./output/q-hoge-fuga.tex
! Missing number, treated as zero.
<to be read again>
\protect
l.1 %% LaTeX2e file `./output/q-hoge-fuga.tex'

となります。
この状態でもう一度、pdflatex を実行すると、

LaTeX Warning: File `./output/q-hoge-fuga.tex' already exists on the system.
Not generating it from this source.

(./output/q-hoge-fuga.tex (./output/q-hoge-fuga.tex (./output/q-hoge-fuga.tex
(./output/q-hoge-fuga.tex (./output/q-hoge-fuga.tex (./output/q-hoge-fuga.tex
(./output/q-hoge-fuga.tex (./output/q-hoge-fuga.tex (./output/q-hoge-fuga.tex
(./output/q-hoge-fuga.tex (./output/q-hoge-fuga.tex (./output/q-hoge-fuga.tex
(./output/q-hoge-fuga.tex (./output/q-hoge-fuga.tex
! TeX capacity exceeded, sorry [text input levels=15].
<argument> "./output/q-hoge-fuga.tex"

l.1 %% LaTeX2e file `./output/q-hoge-fuga.tex'

となります。 (再帰的に読み込もうとしている?)

どのようにすれば意図通りの動作になりますでしょうか?


\documentclass{article}
\usepackage{xstring}

\begin{document}

\def\outdir{./output/}
\def\mkfilename#1{
\StrSubstitute{#1}{:}{-}[\filename]
\edef\filename{\outdir\filename.tex}
% 結果を変数に格納する
% (できれば文字列を返し、\newenvironment の中で、\def\filename{\mkfilename{#1}} とかしたい)
}

% 第一引数は xx:yy:zz のような形式のラベル。
% xx 等には特殊な文字や空白などは入らないと仮定。
% この文字列中の : を - に変えたファイル名でファイル作成したい。
% (変更前の文字列は、tcolorbox でラベルを付けるために使用)
\newenvironment{question}[2]{%
\mkfilename{#1}
\csname filecontents\endcsname{\filename}%
%
% \begin{filecontents}{\filename}%
% だと上手くいかない
%
% 後でここに \begin{tcolorbox} を追加したい
% (#2 は tcolorbox 用)
}{% 後でここに \end{tcolorbox} を追加したい
%
% \end{filecontents} % だと上手くいかない
\csname endfilecontents\endcsname%
\input{\filename}% (*1) これが上手くいかない <-----
}

% ./output/q-hoge-fuga.tex としてファイルを作成したい
\begin{question}{q:hoge:fuga}{Title}
$E = mc^{2}$
\end{question}

\end{document}


追加の質問 (こちらは無視していただいても結構です):

上記コードで \begin{filecontents}{\filename}, \end{filecontents} だと以下のようなエラーが出るのですが、
なぜなのでしょう?
(上のコードは検索で出てきたものを参考に書きました)。

LaTeX Warning: Writing file `././output/q-hoge-fuga.tex'.

)
Runaway argument?
! File ended while scanning use of ^^M.
<inserted text>
\par
<*> q.tex

どうしてもコンパイルしません。

- 宮沢 弘 の投稿
全く初等的な質問ですが、以下のTeXファイルをコンパイルしようとしてもエラーしてしまいます。Googleや、DuckDuckGoを使っても無駄でした。どこを直せばよいのでしょうか?なお、動作環境は windows 10pro バージョン1909、またTeXは、「改訂第7版LATEX2ε美文書作成入門」付属のDVDROMをPCにインストールして使っています。

以下のファイルです。

\documentclass[a4]{jsarticle}

\usepackage{amsmath, amssymb}

\usepackage{latexsym}

\usepackage{overcite}

\usepackage{amsthm}

\begin{document}

\noindent

\textbf{質問1} \\

\hspace{0.3cm}(458page)なぜ$\textbf{H_j}$は実ヒルベルト空間になるのでしょうか?\\

\end{document}



また、ログの表示は

This is ptex2pdf[.lua] version 20170622.0.

Processing texforum.tex

This is e-pTeX, Version 3.14159265-p3.7.1-161114-2.6 (utf8.sjis) (TeX Live 2017/W32TeX) (preloaded format=platex)

restricted \write18 enabled.

entering extended mode

(./texforum.tex

pLaTeX2e <2017/10/28>+4 (based on LaTeX2e <2017-04-15>)

Babel <3.17> and hyphenation patterns for 84 language(s) loaded.

(c:/texlive/2017/texmf-dist/tex/platex/jsclasses/jsarticle.cls

Document Class: jsarticle 2017/10/04 jsclasses (okumura, texjporg)

(c:/texlive/2017/texmf-dist/tex/platex/jsclasses/jslogo.sty))

(c:/texlive/2017/texmf-dist/tex/latex/amsmath/amsmath.sty

For additional information on amsmath, use the `?' option.

(c:/texlive/2017/texmf-dist/tex/latex/amsmath/amstext.sty

(c:/texlive/2017/texmf-dist/tex/latex/amsmath/amsgen.sty))

(c:/texlive/2017/texmf-dist/tex/latex/amsmath/amsbsy.sty)

(c:/texlive/2017/texmf-dist/tex/latex/amsmath/amsopn.sty))

(c:/texlive/2017/texmf-dist/tex/latex/amsfonts/amssymb.sty

(c:/texlive/2017/texmf-dist/tex/latex/amsfonts/amsfonts.sty))

(c:/texlive/2017/texmf-dist/tex/latex/base/latexsym.sty)

(c:/texlive/2017/texmf-dist/tex/latex/cite/overcite.sty)

(c:/texlive/2017/texmf-dist/tex/latex/cite/cite.sty)

(c:/texlive/2017/texmf-dist/tex/latex/amscls/amsthm.sty)


LaTeX Warning: Unused global option(s):

[a4].


(./texforum.aux) (c:/texlive/2017/texmf-dist/tex/latex/amsfonts/umsa.fd)

(c:/texlive/2017/texmf-dist/tex/latex/amsfonts/umsb.fd)

(c:/texlive/2017/texmf-dist/tex/latex/base/ulasy.fd)

! Missing $ inserted.

<inserted text>

$

l.9 \hspace{0.3cm}(458page)なぜ$\textbf{H_j}

$は実ヒルベルト空間になるのでし...

?


です。よろしくお願いいたします。

TeXShopでの矩形選択について

- 松澤 寛 の投稿
初めまして。松澤寛と申します。

MacのKeynoteで作った図をpdfにして、TeXshopで読み込み、矩形選択ツール
にて選択し、「プレビュー」から「選択部分をファイルに保存」を選択し、epsに変換するのをやっております。

新しいPCでやってみましたら「選択部分をファイルに保存」 を選んでも先に進まなくて困っております。

以下、環境です。
MacBook Pro(Catalina 10.15.5)
TeXShop(ver 4.44)

TeXは5月頭にMacTeXを用いてインストールしました。

お忙しいところ大変恐縮ですが、よろしくお願いいたします。

LuaTeX-jaとtcolorboxの禁則処理

- Yuishin の投稿
ディストリビューション: TeX Live 2020
OS: Windows 10 (x64)

LuaTeX-jaとtcolorboxを用いて文書を書いていたのですが、
tcolorboxの中で禁則処理がまったく行われておらず、困っています。

%----------

\documentclass[a4j,12pt]{ltjsarticle}


\usepackage[no-math]{luatexja-fontspec}

\usepackage[deluxe,haranoaji]{luatexja-preset}

\usepackage{tcolorbox}


\begin{document}


\begin{tcolorbox}

禁則処理。禁則処理。禁則処理。禁則処理。禁則処理。「禁則処理。」「禁則処理。」

「禁則処理。」「禁則処理。」「禁則処理。」

\end{tcolorbox}


\end{document}

%----------


対処法をご存知のかたがいらっしゃいましたら、ご回答をお願いします。


%==========

EDIT 1:

tcolorboxに限らず、minipageで禁則処理がなされていないようです。


\begin{minipage}{10\zw}

禁則処理。禁則処理。禁則処理。禁則処理。禁則処理。「禁則処理。」「禁則処理。」

「禁則処理。」「禁則処理。」「禁則処理。」

\end{minipage}

LuaTeX-jaとiwonaフォント

- Yuishin の投稿
ディストリビューション: TeX Live 2020
OS: Windows 10 Pro (x64)

今までpLaTeXを使ってきたのですが、LuaLaTeXへ移行しようと考えています。
そこで、ずっと使ってきた数式フォントのiwonaを引き継ぎたいと思って、以下のコードを書きました。

%----------

\documentclass[a4paper]{ltjsarticle}

\usepackage[no-math,deluxe,haranoaji]{luatexja-preset}

\usepackage[math]{iwona}

\usepackage[T1]{fontenc}


\begin{document}


\[

\int_0^1\sqrt{1-x^2}\,dx

= \pi/4

\approx 0.785398163

\]


Hey! ABCDEFG 12345


\end{document}

%----------


数式部分の数字だけデフォルトから変わらないという奇妙な挙動をします。

プリアンブルからLuaTeX-jaを取り除くと正常になるのですが、

作ろうとしているのは日本語のドキュメントです。

LuaTeX-jaを使いつつiwonaを使いたいのですが、適切な設定を教えていただけないでしょうか。


LuaLaTex-jaの\ltjgetparameterについて

- ebal の投稿
LuaTeX-jaで行あたりの文字数とページあたりの行数を指定するためにマクロを作成して対応しようとしています.調べたところpTeX用らしきマクロが出てきたのでそれを移植しようとしています.

\makeatletter
\def\mojiparline#1{
\newcounter{mpl}
\setcounter{mpl}{#1}
\@tempdima=\linewidth
\advance\@tempdima by-\value{mpl}\zw
\addtocounter{mpl}{-1}
\divide\@tempdima by \value{mpl}
\newdimen\@tempkskip
\@tempkskip=\ltjgetparameter{kanjiskip}
\advance\@tempkskip by \@tempdima
\ltjsetparameter{kanjiskip=\@tempkskip}
\advance\parindent by\@tempdima
}
\makeatother
\def\linesparpage#1{
\baselineskip=\textheight
\divide\baselineskip by #1
}

をヘッダに追加してdocument環境内で

\mojiparline{XX}
\linesparpage{YY}

と指定すれば使えそうだというところまでは来ました.
ただ,\mojiparline{XX} を指定した時にマクロ内の\@tempkskip=\ltjgetparameter{kanjiskip} によって現在の数値が"plus 0.92476pt minus 0.0924pt" このように表示されてしまいます.
これを表示させない方法,あるいはマクロの間違いを指摘していただきたいです.

説明のために抜き出したのが上ですが,動作するファイルを添付します.

追記:
私の環境を明記します.
- OS : Arch Linux
- TeX : TeXLive 2020.55416-1
- LuaLaTeX : This is LuaHBTeX, Version 1.12.0 (TeX Live 2020/Arch Linux)

GlyphWiki のサーバーが、落ちていませんか?

- mr2h の投稿
昨日8月2日から、どうも様子がおかしいようです。
どなたか、確かめて下さいませんか?

見出しをtikzでカスタマイズ

- A S の投稿
sectionをtikzでデザインしようと,

\renewcommand{\section}[1]{<tikz環境>}

のようにすると理想通りのデザインにできるのですが,再定義したことによりヘッダーや目次で節番号は反映されるのですが(命令の中にaddtocounterを含めたため),節タイトルは反映されなくなってしまいます.

節タイトルを反映したままtikzを導入するにはどのようにしたら良いでしょうか?

例えば,暫定的に以下の例で考えてくださると助かります.

¥documentclass[dvipdfmx]{jsarticle}
¥usepackage{tikz}

¥renewcommand{¥section}[1]{
¥addtocounter{section}{1}¥tikz[remember picture,overlay]{
¥draw[line width=1.5pt] (5,-1)circle(0.7) node[below right,black]{¥hspace{10mm}¥LARGE¥bf{#1}} node {{¥bf¥LARGE ¥thesection}};}¥newline}

¥begin{document}
¥section{タイトル}
¥end{document}

半分ずれた表の書き方

- toru toru の投稿
添付画像のような、半分ずれた表を組みたいのですが、TeXでどのように記述すればよいのでしょうか。

現在大学1年生で、コンピューターリテラシーの講義で少しTeXを触った程度の知識です。
資料としてLaTeX美文書作成入門は手元にあるのですが、表組みのところには詳しい記述は見当たりませんでした。

ネット検索したところ、Excelで実現する方法は記述があったのですが、TeXに関しては見つけることができませんでした。

よろしくお願いいたします。
添付 Ed00yt2UEAMq2ub.jpeg

fancyhdr 偶奇によるヘッダーの変更

- A S の投稿
以下をコンパイルして偶数ページのヘッダーはa,奇数ページのヘッダーはbと表示されるようにしたいのですが,ともにbとなってしまいます.
尚,jsbookではa,bと表示されます.
何故でしょうか?

¥documentclass{jsarticle}
¥usepackage{fancyhdr}
¥pagestyle{fancy}
¥rhead[a]{b}
¥begin{document}
¥section{タイトル1}
本文
¥newpage
¥section{タイトル2}
本文
¥end{document}