addmargin - 不需要的换行符和缩进

addmargin - 不需要的换行符和缩进

我想在版权页上为一本书设置一个 bibtex 条目。我尝试设置边距以实现干净的对齐和缩进,而不受实际包含的文本的影响。不幸的是,addmargin添加了换行符,有时还添加了缩进。

\documentclass{scrbook}
\setcounter{tocdepth}{0}% Allow only \chapter in ToC


\newcommand{\poemauthor}{Hugo Ball}
\newcommand{\bknr}{1} 
\newcommand{\isbn}{xxx-xxxxxxxxxx} 
\newcommand{\copyrightyear}{2019} 
\newcommand{\verlag}{Gerastree Indices}
\newcommand{\buchtitel}{\poemauthor: Die Gedichte \\  Lemmatisierter Index }
\newcommand{\auf}{Andrew U. Frank}
\newcommand{\civ}{Christine Ivanovic} 
\newcommand{\engltitel}{\poemauthor: The Poems \\ Lemmatized Index}

\usepackage{fontspec}
\newfontfamily{\codefont}{CMU_Typewriter Text} %{TeXGyrePagella}

\begin{document}

  \begin{codefont}
    \begin{addmargin}[10mm]{0mm}
        @Book\{frank2019{\poemauthor},\\
        title   = {\begin{addmargin}[2cm]{0cm}
                \buchtitel  \\  %adjust layout later when title fixed 
                \engltitel,  

            \end{addmargin}
        }  
        publisher = {\verlag},\\
        series = {\verlag Indices},\\
        year    = {\copyrightyear},\\
        author  = {\begin{addmargin}[2cm]{0cm} 
                \auf {} and \\\civ,\\
            \end{addmargin}
        }
        isbn    = {\isbn},\\
        \} \\
    \end{addmargin}
  \end{codefont}


\end{document}

输出为:

在此处输入图片描述

所需的输出可以是任何结构化的内容,例如:

@Book{frank2019Hugo Ball,
    title = Hugo Ball: Die Gedichte
                Lemmatisierter Index
                Hugo Ball: The Poems
                Lemmatized Index,
    publisher = Gerastree Indices,
    series = Gerastree IndicesIndices,
    year = 2019,
    author =    Andrew U. Frank and
                Christine Ivanovic,
isbn = xxx-xxxxxxxxxx,
}

答案1

addmargin使用“琐碎”列表。因此它会产生新的段落。

您可以使用表格来获得所需的结果:

\documentclass{scrbook}
\usepackage{array}
\setcounter{tocdepth}{\chaptertocdepth}% Allow only \chapter in ToC

\newcommand{\poemauthor}{Hugo Ball}
\newcommand{\bknr}{1} 
\newcommand{\isbn}{xxx-xxxxxxxxxx} 
\newcommand{\copyrightyear}{2019} 
\newcommand{\verlag}{Gerastree Indices}
\newcommand{\buchtitel}{\poemauthor: Die Gedichte \\  Lemmatisierter Index }
\newcommand{\auf}{Andrew U. Frank}
\newcommand{\civ}{Christine Ivanovic} 
\newcommand{\engltitel}{\poemauthor: The Poems \\ Lemmatized Index}

\usepackage{fontspec}
\newfontfamily{\codefont}{DejaVu Sans Mono}% I do not have your fonts

\newbox\mybox

\begin{document}
Maybe you want:

\begingroup
  \codefont
  \savebox\mybox{publisher = }
  \begin{addmargin}[10mm]{0mm}
    @Book\{frank2019{\poemauthor},\\
    \begin{tabular}{@{}p{\wd\mybox}@{}>{\raggedright}p{\dimexpr\linewidth-\wd\mybox}@{}}
      title = & \buchtitel\\ \engltitel,
    \end{tabular}\\
    publisher = {\verlag},\\
    series = {\verlag Indices},\\
    year    = {\copyrightyear},\\
    \begin{tabular}{@{}p{\wd\mybox}@{}>{\raggedright}p{\dimexpr\linewidth-\wd\mybox}@{}}
      author = & \auf {} and \\ \civ,
    \end{tabular}\\
    isbn    = {\isbn},\\
    \}
  \end{addmargin}
\endgroup

\bigskip
or:
\bigskip

\begingroup
  \codefont
  \savebox\mybox{publisher = }
  \begin{addmargin}[10mm]{0mm}
    @Book\{frank2019{\poemauthor},\\
    \begin{tabular}{@{}p{\wd\mybox}@{}>{\raggedright}p{\dimexpr\linewidth-\wd\mybox}@{}}
      &\hspace*{-\wd\mybox}title = \buchtitel\\ \engltitel,
    \end{tabular}\\
    publisher = {\verlag},\\
    series = {\verlag Indices},\\
    year    = {\copyrightyear},\\
    \begin{tabular}{@{}p{\wd\mybox}@{}>{\raggedright}p{\dimexpr\linewidth-\wd\mybox}@{}}
      author = & \auf {} and \\ \civ,
    \end{tabular}\\
    isbn    = {\isbn},\\
    \}
  \end{addmargin}
\endgroup
\end{document}

在此处输入图片描述

答案2

verbatim我认为,在作业结束时将其作为环境添加并手动填充数据会更简单。毕竟,这是一次性的事情。

使用宏,您可以使用\hangindent

\documentclass{scrbook}
\usepackage{fontspec}

\newfontfamily{\codefont}{CMU Typewriter Text} %{TeXGyrePagella}

\newcommand{\poemauthor}{Hugo Ball}
\newcommand{\bknr}{1} 
\newcommand{\isbn}{xxx-xxxxxxxxxx} 
\newcommand{\copyrightyear}{2019} 
\newcommand{\verlag}{Gerastree Indices}
\newcommand{\buchtitel}{\poemauthor: Die Gedichte \\ Lemmatisierter Index }
\newcommand{\auf}{Andrew U. Frank}
\newcommand{\civ}{Christine Ivanovic} 
\newcommand{\engltitel}{\poemauthor: The Poems \\ Lemmatized Index}

\setcounter{tocdepth}{0}% Allow only \chapter in ToC

\begin{document}

\begin{sloppy}
\codefont\settowidth{\dimen0}{A}
\setlength{\parindent}{2\dimen0}
\setlength{\leftskip}{3\dimen0}% decide how you want it
\noindent
@Book\{frank2019{\poemauthor},\par
\hangindent=11\dimen0
title = \{\buchtitel\newline
        \engltitel\},\par
publisher = \{\verlag\},\par
series = \{\verlag\ Indices\},\par
year = \{\copyrightyear\},\par
\hangindent=12\dimen0
author = \{\auf{} and\newline 
              \civ\},\par
isbn = \{\isbn\},\par
\noindent\}\par
\end{sloppy}

\end{document}

在此处输入图片描述

相关内容