更新

更新

因此,我尝试使用 排版一篇文章,\LaTeX需要musixtex。为了使事情变得简单,我做了一些宏。一切正常,只是我似乎无法得到任何(音乐)垂直小节线(除了微小的点)。一无所获,我用 vanilla 重写了我的宏\TeX,但... 一无所获。我的文档是有点喜欢:

\documentclass{article}

\usepackage{amsmath}
\usepackage{musixtex}
\usepackage{graphicx}

% Emits a pitchless duration (stems up). Hides the ugliness of musixtex.
% Usage: \beat{duration}
% Where: duration in [1, 2, 4, 8, 16, 32, 64].
\def\beat#1{
\ifnum#1=1
{\wh{i}} % whole
\else{
    \ifnum#1=2
    {\hu{i}} % half
    \else{
        \ifnum#1=4
        {\qu{i}} % quarter
        \else{
            \ifnum#1=8
            {\cu{i}} % eighth
            \else{
                \ifnum#1=16 
                {\ccu{i}} % sixteenth
                \else{
                    \ifnum#1=32 
                    {\cccu{i}} % thirty-second 
                    \else{{\ccccu{i}}}\fi % sixty-fourth
                }\fi
            }\fi
        }\fi
    }\fi
}\fi
}

% Emits a single measure.
% Usage: \measure{notes}
% Where: notes is a sequence of \beat{?} or \rest{?}
\def\measure#1{\Notes #1\en\bar}

% Null clef.
\def\nullclef{\raise2\internote\hbox{\keychar77}}

% Emits a single-line staff rhythmic example with one or 
% more measures.
% Usage: \rhythm{num}{den}{measures}
% Where: num, den are the meter.
%        measures is one or more \measure{notes}
\def\rhythm#1#2#3{\begin{music}
    \nobarnumbers
    \instrumentnumber{1}
    \generalmeter{\meterfrac{#1}{#2}}
    \setstaffs1{1}
    \setclefsymbol1{\nullclef}
    \setlines1{1}
    \sepbarrules
    \startextract
    #3
    \endextract
\end{music}}

\begin{document}

\title{Rhythmic Whatnot}
\maketitle

\begin{abstract}
Stuff about rhythmic structure with machine learning.
\end{abstract}

\section{Introduction}

Waffle on forever. For example, with $n = 4$ and $\left\{2, 1, 1\right\}$, then:

\rhythm{2}{4}{
    \measure{\beat{4}\beat{8}\beat{8}}
    \measure{\beat{8}\beat{4}\beat{8}}
    \measure{\beat{8}\beat{8}\beat{4}}
    }

Therefore, it is obvious.

\end{document}

我想象我只做错了一件简单的事情,但我却看不到它,即使经过几天的摆弄。

答案1

更新

这是与 相关的错误MusiXTeX(c) 1.27 <2017-12-26>,已在 中修复MusiXTeX(c) 1.28 <2018-05-07>。您应该更新该软件包。

如果您无法更新,您可以在文档中手动修复此错误。将以下内容添加到您的序言中并忽略我的原始答案:

\usepackage{regexpatch}

\makeatletter
\regexpatchcmd{\C@Inter}{=}{<}{}{}
\xpatchcmd{\C@Inter}{\thr@@}{\f@ur}{}{}
\makeatother

完整 MWE(版本 1.27):

\documentclass{article}

\usepackage{amsmath}
\usepackage{musixtex}
\usepackage{graphicx}

% to fix a bug in musixtex version <1.28
\usepackage{regexpatch}

\makeatletter
\regexpatchcmd{\C@Inter}{=}{<}{}{}
\xpatchcmd{\C@Inter}{\thr@@}{\f@ur}{}{}
\makeatother
% end fix

% Emits a pitchless duration (stems up). Hides the ugliness of musixtex.
% Usage: \beat{duration}
% Where: duration in [1, 2, 4, 8, 16, 32, 64].
\def\beat#1{
  \ifnum#1=1
  {\wh{i}} % whole
  \else{
    \ifnum#1=2
    {\hu{i}} % half
    \else{
      \ifnum#1=4
      {\qu{i}} % quarter
      \else{
        \ifnum#1=8
        {\cu{i}} % eighth
        \else{
          \ifnum#1=16 
          {\ccu{i}} % sixteenth
          \else{
            \ifnum#1=32 
            {\cccu{i}} % thirty-second 
            \else{{\ccccu{i}}}\fi % sixty-fourth
          }\fi
        }\fi
      }\fi
    }\fi
  }\fi
}

% Emits a single measure.
% Usage: \measure{notes}
% Where: notes is a sequence of \beat{?} or \rest{?}
\def\measure#1{\Notes #1\en\bar}
\def\measuree#1{\Notes #1\en}

% Null clef.
\def\nullclef{\raise2\internote\hbox{\keychar77}}

% Emits a single-line staff rhythmic example with one or 
% more measures.
% Usage: \rhythm{num}{den}{measures}
% Where: num, den are the meter.
%        measures is one or more \measure{notes}
\def\rhythm#1#2#3{\begin{music}
  \nobarnumbers
  \instrumentnumber{1}
  \generalmeter{\meterfrac{#1}{#2}}
  \setstaffs1{1}
  \setclefsymbol1{\nullclef}
  \setlines1{1}
  \sepbarrules
  \startextract
  #3%
  \endextract
\end{music}}

\begin{document}

  \title{Rhythmic Whatnot}
  \maketitle

  \begin{abstract}
    Stuff about rhythmic structure with machine learning.
  \end{abstract}

  \section{Introduction}

  Waffle on forever. For example, with $n = 4$ and $\left\{2, 1, 1\right\}$, then:

  \rhythm{2}{4}{%
    \measure{\beat{4}\beat{8}\beat{8}}
    \measure{\beat{8}\beat{4}\beat{8}}
    \measuree{\beat{8}\beat{8}\beat{4}}%
  }

  Therefore, it is obvious.

\end{document}

result

技术细节:阅读很有帮助,就像在1.28更新日志中写的那样

% version 1.28

% defined 
%  \z[left|right|leftright]repeat, for use *within* a bar
%  \zz...repeat, to force to the end of a system
% corrected definition of \C@Inter for \nblines < 4

如果查看定义

\def\C@Inter{%  RDT: corrected to work if \nblines > 6   (version 1.23)

在第 1831 行 (v1.27) 或第 1838 行 (v1.28) 中,可以找到以下内容diff

<   \ifnum\nblines=\thr@@
---
>   \ifnum\nblines<\f@ur

因此我认为这是一个错误,应该更新,但作为一种解决方法,我提出的解决方案似乎有效。


原始答案

不确定为什么@egreg似乎已经得到了想要的(?)结果,但我找到了一个解决方法MusiXTeX(c) 1.27 <2017-12-26>

\documentclass{article}

\usepackage{amsmath}
\usepackage{musixtex}
\usepackage{graphicx}

% Emits a pitchless duration (stems up). Hides the ugliness of musixtex.
% Usage: \beat{duration}
% Where: duration in [1, 2, 4, 8, 16, 32, 64].
\def\beat#1{
  \ifnum#1=1
  {\wh{i}} % whole
  \else{
    \ifnum#1=2
    {\hu{i}} % half
    \else{
      \ifnum#1=4
      {\qu{i}} % quarter
      \else{
        \ifnum#1=8
        {\cu{i}} % eighth
        \else{
          \ifnum#1=16 
          {\ccu{i}} % sixteenth
          \else{
            \ifnum#1=32 
            {\cccu{i}} % thirty-second 
            \else{{\ccccu{i}}}\fi % sixty-fourth
          }\fi
        }\fi
      }\fi
    }\fi
  }\fi
}

% Emits a single measure.
% Usage: \measure{notes}
% Where: notes is a sequence of \beat{?} or \rest{?}
\def\measure#1{\Notes #1\en\bar}
\def\measuree#1{\Notes #1\en} % <-- added

% Null clef.
\def\nullclef{\raise2\internote\hbox{\keychar77}}

% Emits a single-line staff rhythmic example with one or 
% more measures.
% Usage: \rhythm{num}{den}{measures}
% Where: num, den are the meter.
%        measures is one or more \measure{notes}
\def\rhythm#1#2#3{\begin{music}
  \nobarnumbers
  \instrumentnumber{1}
  \generalmeter{\meterfrac{#1}{#2}}
  \setstaffs1{1}
  \setclefsymbol1{\nullclef}
  \setlines1{1}
  \sepbarrules
  \startextract\setlines1{5}% <-- added
  #3%
  \endextract
\end{music}}

\begin{document}

  \title{Rhythmic Whatnot}
  \maketitle

  \begin{abstract}
    Stuff about rhythmic structure with machine learning.
  \end{abstract}

  \section{Introduction}

  Waffle on forever. For example, with $n = 4$ and $\left\{2, 1, 1\right\}$, then:

  \rhythm{2}{4}{%
    \measure{\beat{4}\beat{8}\beat{8}}
    \measure{\beat{8}\beat{4}\beat{8}}
    \measuree{\beat{8}\beat{8}\beat{4}}% <-- changed
  }

  Therefore, it is obvious.

\end{document}

image result

似乎会\bar根据线条高度创建条形图。如果在之后更改该设置\startextract,则可以修改条形图而不会影响打印的线条。但不确定这是否是一项功能。

我还为“测量结束”创建了一个没有条形图的新宏\measuree,以删除末尾的双条形图。

相关内容