
私はtitlesec
自分の本の各章の著者と翻訳者を次のように示しています。
\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage{titlesec}
\newcommand{\chapterauthor}{}
\newcommand{\chaptertranslator}{}
\titleformat{\chapter}% command to format the chapter titles
[hang]% shape/type of title
{\LARGE\bfseries}% formatting commands applied to both label and title
{\makebox[0.5in][l]{\thechapter}}% chapter number; here set inside an invisible box with a constant width
{0em}% separation between number and chapter title; we've already covered this with the box
{}% additional formatting command for title itself not applied to number
[% everything inside [...] below comes after the title
\hfill%
\normalsize\normalfont% reset font formatting
\vspace{0.5\baselineskip}% add a half-space of vertical space before author
\hspace*{0.5in}% indent author name width of chapter number box
\begin{tabular}{rl} %
Author: & \kern-0.5em\chapterauthor \\
Translator: & \kern-0.5em\chaptertranslator\\
\end{tabular}%
]% end of what comes after title
\titlespacing*{\chapter}% spacing commands for chapter titles; the star unindents first line afterwards
{0em}% spacing to left of chapter title
{0ex}% vertical space before title
{3\baselineskip}% vertical spacing after title; here set to 3 lines
\begin{document}
\tableofcontents
\renewcommand{\chapterauthor}{Alphonse Lamartine}
\renewcommand{\chaptertranslator}{Ine}
\chapter{New chapter}
Here it is.
\renewcommand{\chapterauthor}{Heinrich Böll}
\renewcommand{\chaptertranslator}{Llöb Chirnieh}
\chapter{Another chapter}
Here again.
\end{document}
各章ごとに、著者と翻訳者を次のように再定義します。
\renewcommand{\chapterauthor}{Heinrich Böll}
\renewcommand{\chaptertranslator}{Llöb Chirnieh}
問題は、目次を章として扱うことです。目次の作成者や翻訳者はいないため、次のように目次のすぐ上に空の著者と翻訳者が表示されます。
Author:
Translator:
これを防ぐにはどうしたらいいでしょうか?
\boolfalse{withauthor}
===編集: のコメントではBernard
不十分であることを示す===
\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{etoolbox}
\newbool{withauthor}
\newcommand{\chapterauthor}{}
\newcommand{\chaptertranslator}{}
\titleformat{\chapter}% command to format the chapter titles
[hang]% shape/type of title
{\LARGE\bfseries}% formatting commands applied to both label and title
{\makebox[0.5in][l]{\thechapter}}% chapter number; here set inside an invisible box with a constant width
{0em}% separation between number and chapter title; we've already covered this with the box
{}% additional formatting command for title itself not applied to number
[% everything inside [...] below comes after the title
\ifbool{withauthor}{\hfill%
\normalsize\normalfont% reset font formatting
\vspace{0.5\baselineskip}% add a half-space of vertical space before author
\hspace*{0.5in}% indent author name width of chapter number box
\begin{tabular}{rl} %
Author: & \kern-0.5em\chapterauthor \\
Translator: & \kern-0.5em\chaptertranslator\\
\end{tabular}}{}%
\boolfalse{withauthor}
]% end of what comes after title
\titlespacing*{\chapter}% spacing commands for chapter titles; the star unindents first line afterwards
{0em}% spacing to left of chapter title
{0ex}% vertical space before title
{3\baselineskip}% vertical spacing after title; here set to 3 lines
\begin{document}
\tableofcontents
\renewcommand{\chapterauthor}{Alphonse Lamartine}
\renewcommand{\chaptertranslator}{Ine}
\booltrue{withauthor}
\chapter{New chapter}
Here it is.
%\renewcommand{\chapterauthor}{Heinrich Böll}
%\renewcommand{\chaptertranslator}{Llöb Chirnieh}
%\boolfalse{withauthor}
\chapter{Another chapter}
Here again.
\end{document}
答え1
番号が付いていない章には著者も翻訳者もいないと思いますが、番号が付いている章には著者も翻訳者もいると思います。
\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{lipsum}
\usepackage{array}
\usepackage{titlesec}
\usepackage{etoolbox}
\newbool{withauthor}
\newcommand{\chapterauthor}{}
\newcommand{\chaptertranslator}{}
\titleformat{\chapter}% command to format the chapter titles
[hang]% shape/type of title
{\LARGE\bfseries}% formatting commands applied to both label and title
{\makebox[0.5in][l]{\thechapter}}% chapter number; here set inside an invisible box with a constant width
{0em}% separation between number and chapter title; we've already covered this with the box
{}% additional formatting command for title itself not applied to number
[% everything inside [...] below comes after the title
\ifbool{withauthor}{\hfill%
\normalsize\normalfont% reset font formatting
\vspace{0.5\baselineskip}% add a half-space of vertical space before author
\hspace*{0.5in}% indent author name width of chapter number box
\begin{tabular}{ll} %
Author: & \kern-0.5em\chapterauthor \\
Translator: & \kern-0.5em\chaptertranslator\\
\end{tabular}}{}%
\global\boolfalse{withauthor}
]% end of what comes after title
\titlespacing*{\chapter}% spacing commands for chapter titles; the star unindents first line afterwards
{0em}% spacing to left of chapter title
{0ex}% vertical space before title
{3\baselineskip}% vertical spacing after title; here set to 3 lines
\begin{document}
\tableofcontents
\renewcommand{\chapterauthor}{Alphonse de Lamartine}
\renewcommand{\chaptertranslator}{Ine}
\booltrue{withauthor}
\chapter{New chapter}
Here it is.
%\renewcommand{\chapterauthor}{Heinrich Böll}
%\renewcommand{\chaptertranslator}{Llöb Chirnieh}
%\boolfalse{withauthor}
\chapter{Another chapter}
Here again.
\end{document}