使用 Beamer 与 Tikz 和 Musixtex 为 musix 环境左移节点区域

使用 Beamer 与 Tikz 和 Musixtex 为 musix 环境左移节点区域

Beamer 配合 Tikz 和 Musixtex 使用时,需要对 musix 环境的节点区域进行左移,基本代码如下:

\documentclass[aspectratio=169]{beamer}
\usepackage{musixtex}
\usepackage{minted}
\usemintedstyle{borland}
\setlength{\fboxsep}{0pt}%Color boxes start with a 
%small but noticeable space, which can be annoying 
%when highlighting whole lines of Python 
%where indentation matters, this command prevent it.

\usepackage[T1]{fontenc}
\usepackage{emerald}%Fuente tipo mano para pizarra en Beamer
\usepackage[spanish]{babel}
%Paquetes para Beamer
\usepackage{calc}
\usepackage{ifthen}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgffor}
\usepackage{float} %Paquete para posicionar Tablas
\usepackage{adjustbox}%Para centrar tablas
\usepackage{xcolor}
\xdefinecolor{gray-undar}{RGB}{52,52,52}
\xdefinecolor{red-undar}{RGB}{179,35,79}
% set text colors for different objects
\setbeamercolor{frametitle}{fg=white}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{alerted text}{fg=white}
\setbeamercolor{example text}{fg=white}
%% set fonts
\setbeamerfont{frametitle}{size=\Huge, series=\ECFAugie}
\setbeamerfont{framesubtitle}{size=\large, series=\ECFAugie}
\setbeamerfont{title}{size=\huge, series=\ECFAugie}
\setbeamerfont{author}{size=\large, series=\ECFAugie}
\setbeamerfont{date}{size=\large, series=\ECFAugie}
\setbeamerfont{institute}{size=\large, series=\ECFAugie}
\setbeamerfont{caption}{series=\ECFAugie}
%% Green Background Colour
\setbeamercolor{background canvas}{bg=green!18!black}
%% Random Dust Trails
\setbeamertemplate{background}{
    \begin{tikzpicture}
        \useasboundingbox (0,0) rectangle (\the\paperwidth, \the\paperheight); 
      \foreach \i in {1,...,30} {
            \pgfmathsetmacro{\x}{random(0,10000)/5000-1}%
            \pgfmathsetmacro{\y}{random(0,10000)/10000-0.1}%
            \pgfmathsetmacro{\r}{random(0,10000)/1000-5}%
            \rotatebox{\r}{
                %\pgftext[at=\pgfpoint{\x\paperwidth}{\y\paperheight}, left, base]{\includegraphics[width=\textwidth]{LOGO_UNDAR_PNG_RGB.png}}
            }
        }; 
    \end{tikzpicture}
}
%% use a small dash ('-') for a bulletpoint list
\setbeamertemplate{itemize item}{\usebeamercolor[fg]{item}\small\ECFAugie{-}}
%% Frametitle
\setbeamertemplate{frametitle}{
    \begin{beamercolorbox}{frametitle}
        \vskip17pt
        \usebeamerfont{frametitle}
        \insertframetitle \\
        \usebeamerfont{framesubtitle}\insertframesubtitle
    \end{beamercolorbox}
}
%% remove navigation symbols
\setbeamertemplate{navigation symbols}{}
%% Date in the Corner
\setbeamertemplate{headline}{
    \rotatebox{30}{
        \ifx\insertdate\empty\else        
            \hspace*{0.25cm}\ECFAugie\insertshortdate\hspace*{0.5cm}
        \fi
    }
    \vspace*{-1cm}
}

\begin{document}
\ECFAugie

\begin{frame}[fragile,t]
    \frametitle{\large Códigos en Musixtex}
    \framesubtitle{Codificando Notas}
    
    \normalfont    
    \setbeamercolor{normal text}{fg=black}
    \usebeamercolor[fg]{normal text}
        
    \centering
    \begin{minipage}{0.65\linewidth}    
    \begin{minted}[
    frame=lines,
    framesep=2mm,
    baselinestretch=1.2,
    bgcolor=gray,%gray-undar,
    fontsize=\footnotesize,
    linenos]{latex}
    \begin{music}
    \setclef1\treble % Clave Sol para Instrumento 1
    \nobarnumbers % Omite numeración en compases
    \nostartrule % Inicia sin barra vertical
    \startextract % inicia el fragmento musical
    \NOTEs\wh{ghijkl^mn}\en % Primer compás
    \setdoubleBAR % Pone barra final
    \endextract % Se finaliza el fragmento musical
    \end{music}
    \end{minted}
    \end{minipage}
    \hspace{0.05\linewidth}
    \begin{minipage}{0.25\linewidth}
    \begin{tikzpicture}
    \node[anchor=south west,inner sep=0,scale=1,fill=white,minimum width=6.5cm,minimum height=1.9cm] (EjemCodigo1) at (0,0) {
        \scalebox{0.45}{\hspace*{-2.2cm}\begin{music}
        \setclef1\treble % Clave de la partitura
        \nobarnumbers % Omite numeración compases
        \nostartrule % Inicia sin barra vertical
        \startextract % Se inicia el fragmento musical
        \NOTEs\wh{ghijkl^mn}\en\setdoubleBAR 
        \endextract % Se finaliza el fragmento musical
    \end{music}}
    };
    \end{tikzpicture}
    \end{minipage}
    \setbeamercolor{normal text}{fg=white}
    \usebeamercolor[fg]{normal text}
    
\ECFAugie   
\end{frame}

\end{document}

当前输出如下: 当前的

如何在小页面内将节点向左移动?

答案1

6.5 厘米宽的节点无法放入 .25\linewidth 宽的 minipage(14 厘米/4=3.5 厘米)。您必须使 minipage 至少与节点一样宽才能正确定位它。

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}

\documentclass[aspectratio=169]{beamer}
\usepackage{musixtex}
\usepackage{minted}
\usemintedstyle{borland}
\setlength{\fboxsep}{0pt}%Color boxes start with a 
%small but noticeable space, which can be annoying 
%when highlighting whole lines of Python 
%where indentation matters, this command prevent it.

\usepackage[T1]{fontenc}
\usepackage{emerald}%Fuente tipo mano para pizarra en Beamer
\usepackage[spanish]{babel}
%Paquetes para Beamer
\usepackage{calc}
\usepackage{ifthen}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgffor}
\usepackage{float} %Paquete para posicionar Tablas
\usepackage{adjustbox}%Para centrar tablas
\usepackage{xcolor}
\xdefinecolor{gray-undar}{RGB}{52,52,52}
\xdefinecolor{red-undar}{RGB}{179,35,79}
% set text colors for different objects
\setbeamercolor{frametitle}{fg=white}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{alerted text}{fg=white}
\setbeamercolor{example text}{fg=white}
%% set fonts
\setbeamerfont{frametitle}{size=\Huge, series=\ECFAugie}
\setbeamerfont{framesubtitle}{size=\large, series=\ECFAugie}
\setbeamerfont{title}{size=\huge, series=\ECFAugie}
\setbeamerfont{author}{size=\large, series=\ECFAugie}
\setbeamerfont{date}{size=\large, series=\ECFAugie}
\setbeamerfont{institute}{size=\large, series=\ECFAugie}
\setbeamerfont{caption}{series=\ECFAugie}
%% Green Background Colour
\setbeamercolor{background canvas}{bg=green!18!black}
%% Random Dust Trails
\setbeamertemplate{background}{
    \begin{tikzpicture}
        \useasboundingbox (0,0) rectangle (\the\paperwidth, \the\paperheight); 
      \foreach \i in {1,...,30} {
            \pgfmathsetmacro{\x}{random(0,10000)/5000-1}%
            \pgfmathsetmacro{\y}{random(0,10000)/10000-0.1}%
            \pgfmathsetmacro{\r}{random(0,10000)/1000-5}%
            \rotatebox{\r}{
                %\pgftext[at=\pgfpoint{\x\paperwidth}{\y\paperheight}, left, base]{\includegraphics[width=\textwidth]{LOGO_UNDAR_PNG_RGB.png}}
            }
        }; 
    \end{tikzpicture}
}
%% use a small dash ('-') for a bulletpoint list
\setbeamertemplate{itemize item}{\usebeamercolor[fg]{item}\small\ECFAugie{-}}
%% Frametitle
\setbeamertemplate{frametitle}{
    \begin{beamercolorbox}{frametitle}
        \vskip17pt
        \usebeamerfont{frametitle}
        \insertframetitle \\
        \usebeamerfont{framesubtitle}\insertframesubtitle
    \end{beamercolorbox}
}
%% remove navigation symbols
\setbeamertemplate{navigation symbols}{}
%% Date in the Corner
\setbeamertemplate{headline}{
    \rotatebox{30}{
        \ifx\insertdate\empty\else        
            \hspace*{0.25cm}\ECFAugie\insertshortdate\hspace*{0.5cm}
        \fi
    }
    \vspace*{-1cm}
}

\begin{document}
\ECFAugie

\begin{frame}[fragile,t]
    \frametitle{\large Códigos en Musixtex}
    \framesubtitle{Codificando Notas}
    
    \normalfont    
    \setbeamercolor{normal text}{fg=black}
    \usebeamercolor[fg]{normal text}
        
    \begin{minipage}{0.58\linewidth}    
    \begin{minted}[
    frame=lines,
    framesep=2mm,
    baselinestretch=1.2,
    bgcolor=gray,%gray-undar,
    fontsize=\footnotesize,
    linenos]{latex}
 \begin{music}
 \setclef1\treble % Clave Sol para Instrumento 1
 \nobarnumbers % Omite numeración en compases
 \nostartrule % Inicia sin barra vertical
 \startextract % inicia el fragmento musical
 \NOTEs\wh{ghijkl^mn}\en % Primer compás
 \setdoubleBAR % Pone barra final
 \endextract % Se finaliza el fragmento musical
 \end{music}
    \end{minted}
    \end{minipage}%
    \hfill
    \begin{minipage}{0.38\linewidth}
    \begin{tikzpicture}
    \node[anchor=south west,inner sep=0,scale=1,fill=white,minimum width=\linewidth,minimum height=1.9cm] (EjemCodigo1) at (0,0) {
        \scalebox{0.45}{\begin{music}
        \setclef1\treble % Clave de la partitura
        \nobarnumbers % Omite numeración compases
        \nostartrule % Inicia sin barra vertical
        \startextract % Se inicia el fragmento musical
        \NOTEs\wh{ghijkl^mn}\en\setdoubleBAR 
        \endextract % Se finaliza el fragmento musical
    \end{music}}
    };
    \end{tikzpicture}
    \end{minipage}%
    \setbeamercolor{normal text}{fg=white}
    \usebeamercolor[fg]{normal text}
    
\ECFAugie   
\end{frame}

\end{document}

在此处输入图片描述

相关内容