如何改变文档中公式编号的左右位置?

如何改变文档中公式编号的左右位置?
%
%---------------------------------------------------------------------------------------------------------- %
\documentclass{book} %
%---------------------------------------------------------------------------------------------------------- %
%
\usepackage[fleqn]{amsmath} %
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} % 
\usepackage[many]{tcolorbox}
\usepackage[english]{babel} %
\usepackage{fancyhdr} %
\usepackage{xcolor,colortbl}
\usepackage[a4,frame,center]{crop} % a4=210mm x 297mm

\setlength{\unitlength}{1mm} %

\frontmatter

\paperwidth=170mm
\paperheight=240mm
\setlength{\textwidth}{132mm} %
\setlength{\oddsidemargin}{0mm} %
\setlength{\evensidemargin}{-12mm} %
\setlength{\headwidth}{\textwidth}

\setcounter{section}{1} % was 1
\setcounter{tocdepth}{2} % depth in contents lists
\setcounter{equation}{2}

\definecolor{DarkRed}{rgb}{0.45,0.00,0.00} % #880000
\definecolor{ThemeColour}{rgb}{0.40,0.00,0.40} % ThemeColour maroon
\definecolor{LightGrey}{rgb}{0.96,0.96,0.96}

\newcommand\Hrule{\noindent\color{ThemeColour}{\rule{\linewidth}{3pt}}} %
\newcommand\hseprule{\color{DarkRed}{\rule{\linewidth}{0.8pt}}} %

\titleformat{\chapter}[display]
{\color{ThemeColour}\bfseries\itshape\fontsize{30}{30}\selectfont}
{\Hrule\vspace*{6pt}\\ {\color{black}\,\chaptername\hspace{8pt}\normalfont\fontsize{42}{45}\selectfont{\thechapter}}}
{0pt}
{\bfseries\normalfont\fontsize{15}{18}\selectfont{#1} \\ \vspace*{-9pt}\Hrule} %
[\vspace{18pt}]
\titlespacing{\chapter}{0pt}{12pt}{6pt}[0pt] %
\renewcommand{\thechapter}{\arabic{chapter}} % make-up of the numbering

\tcbset{boxsep=5.4pt,height=18mm,boxrule=1.2pt,arc=3pt,outer arc=3.2pt,valign=center,width=\linewidth,
coltitle=white,colbacktitle=ThemeColour,after=\hfill,colframe=black,colback=LightGrey}

\newtcolorbox{sectionbox}[2][] % create sectionbox
{title={#2},fonttitle=\bfseries,#1}

\titleformat{\section} %
  {\normalfont\bfseries\itshape\fontsize{12}{14}\selectfont}
  {}{0pt}
{\begin{sectionbox}{\fontsize{14}{15}\selectfont{Section\hspace{5.4pt}\thetitle}}{\fontsize{12.8}{15}\selectfont{#1}}
\end{sectionbox}}
\titlespacing{\section}{0pt}{15pt}{6pt}[0pt] %
\renewcommand{\thesection}{\arabic{section}} % make-up of number


% ----------------------- ******* change the style of equation numbering ******* ----------------------------------- %

\makeatletter
\let\mytagform@=\tagform@ % set at 18mm from right - wish to vary this within document
%
\def\tagform@#1{\maketag@@@{\color{DarkRed}{[\hspace{0.5pt}#1\unskip\@@italiccorr\hspace{0.5pt}]}}\hspace{18mm}} % HERE
\renewcommand{\eqref}[1]{\textup{[\ref{#1}]}}
\makeatother

\renewcommand{\theequation}{\hspace{0.8pt}\thechapter\hspace{1.0pt}.\hspace{0.6pt}\arabic{equation}\hspace{0.8pt}} % 0.8pt

% ----------------------------------------- style of equation numbering -------------------------------------------- %

\begin{document}

\mainmatter

\chapter{Introduction to number and simple algebra}

\section{Discovering and manipulating counting numbers}

\setlength{\mathindent}{100pt} % Distance in from left
\begin{equation}
\dfrac{2\hspace{1.0pt}x+3}{4}=\dfrac{5-x}{3} \label{eqn:firstequation}
\end{equation}

\setlength{\mathindent}{130pt} % Distance in from left
\begin{equation}
\dfrac{2\hspace{1.0pt}x+3}{4}=\dfrac{5-x}{3} \label{eqn:secondequation}
\end{equation}

\end{document}

答案1

我不认为这是一个好主意:-)

在此处输入图片描述

%
%---------------------------------------------------------------------------------------------------------- %
\documentclass{book} %
%---------------------------------------------------------------------------------------------------------- %
%
\usepackage[fleqn]{amsmath} %
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} % 
\usepackage[many]{tcolorbox}
\usepackage[english]{babel} %
\usepackage{fancyhdr} %
\usepackage{xcolor,colortbl}
\usepackage[a4,frame,center]{crop} % a4=210mm x 297mm

\setlength{\unitlength}{1mm} %

\frontmatter

\paperwidth=170mm
\paperheight=240mm
\setlength{\textwidth}{132mm} %
\setlength{\oddsidemargin}{0mm} %
\setlength{\evensidemargin}{-12mm} %
\setlength{\headwidth}{\textwidth}

\setcounter{section}{1} % was 1
\setcounter{tocdepth}{2} % depth in contents lists
\setcounter{equation}{2}

\definecolor{DarkRed}{rgb}{0.45,0.00,0.00} % #880000
\definecolor{ThemeColour}{rgb}{0.40,0.00,0.40} % ThemeColour maroon
\definecolor{LightGrey}{rgb}{0.96,0.96,0.96}

\newcommand\Hrule{\noindent\color{ThemeColour}{\rule{\linewidth}{3pt}}} %
\newcommand\hseprule{\color{DarkRed}{\rule{\linewidth}{0.8pt}}} %

\titleformat{\chapter}[display]
{\color{ThemeColour}\bfseries\itshape\fontsize{30}{30}\selectfont}
{\Hrule\vspace*{6pt}\\ {\color{black}\,\chaptername\hspace{8pt}\normalfont\fontsize{42}{45}\selectfont{\thechapter}}}
{0pt}
{\bfseries\normalfont\fontsize{15}{18}\selectfont{#1} \\ \vspace*{-9pt}\Hrule} %
[\vspace{18pt}]
\titlespacing{\chapter}{0pt}{12pt}{6pt}[0pt] %
\renewcommand{\thechapter}{\arabic{chapter}} % make-up of the numbering

\tcbset{boxsep=5.4pt,height=18mm,boxrule=1.2pt,arc=3pt,outer arc=3.2pt,valign=center,width=\linewidth,
coltitle=white,colbacktitle=ThemeColour,after=\hfill,colframe=black,colback=LightGrey}

\newtcolorbox{sectionbox}[2][] % create sectionbox
{title={#2},fonttitle=\bfseries,#1}

\titleformat{\section} %
  {\normalfont\bfseries\itshape\fontsize{12}{14}\selectfont}
  {}{0pt}
{\begin{sectionbox}{\fontsize{14}{15}\selectfont{Section\hspace{5.4pt}\thetitle}}{\fontsize{12.8}{15}\selectfont{#1}}
\end{sectionbox}}
\titlespacing{\section}{0pt}{15pt}{6pt}[0pt] %
\renewcommand{\thesection}{\arabic{section}} % make-up of number


% ----------------------- ******* change the style of equation numbering ******* ----------------------------------- %

\makeatletter
\let\mytagform@=\tagform@ % set at 18mm from right - wish to vary this within document
%
\def\tagform@#1{\maketag@@@{\color{DarkRed}{[\hspace{0.5pt}#1\unskip\@@italiccorr\hspace{0.5pt}]}}\hspace{18mm}} % HERE
\renewcommand{\eqref}[1]{\textup{[\ref{#1}]}}
\makeatother

\renewcommand{\theequation}{\hspace{0.8pt}\thechapter\hspace{1.0pt}.\hspace{0.6pt}\arabic{equation}\hspace{0.8pt}} % 0.8pt

% ----------------------------------------- style of equation numbering -------------------------------------------- %

\begin{document}

\mainmatter

\chapter{Introduction to number and simple algebra}

\section{Discovering and manipulating counting numbers}

\setlength{\mathindent}{100pt} % Distance in from left
\begin{equation}
\dfrac{2\hspace{1.0pt}x+3}{4}=\dfrac{5-x}{3} \label{eqn:firstequation}
\end{equation}

\setlength{\mathindent}{130pt} % Distance in from left
\begin{equation}
\dfrac{2\hspace{1.0pt}x+3}{4}=\dfrac{5-x}{3} \label{eqn:secondequation}
\end{equation}


\setlength{\mathindent}{130pt} % Distance in from left
{\addtolength{\hsize}{-20pt} % Distance in from right
\begin{equation}
\dfrac{2\hspace{1.0pt}x+3}{4}=\dfrac{5-x}{3} \label{eqn:secondequation}
\end{equation}}%

\end{document}

相关内容