我的方程编号都在右侧。我将边距设置为18mm
,但我希望在浏览文档时在任何特定页面上改变此距离。我推测这意味着使用\renewcommand
。这是保留所有必要信息的 MWE。
%---------------------------------------------------------------------------------------------------------- %
\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
方程的右边距可以通过线宽来设置\hsize
。
例子:
\theequation
没有额外的空间。无论如何这都不好,因为amsmath
如果方程太长,包可能会将其移动到方程下方。环境
eq
,设置\mathindent
左边距和\hsize
右边距:\newenvironment{eq}[2]{% \setlength{\mathindent}{#1}% \setlength{\hsize}{\dimexpr\hsize-#2\relax}% \ignorespaces }{\ignorespacesafterend}
用例:
\section{Discovering and manipulating counting numbers}
\begin{eq}{100pt}{18mm}
\begin{equation}
\dfrac{2\hspace{1.0pt}x+3}{4}=\dfrac{5-x}{3} \label{eqn:firstequation}
\end{equation}
\end{eq}
\begin{eq}{130pt}{24mm}
\begin{equation}
\dfrac{2\hspace{1.0pt}x+3}{4}=\dfrac{5-x}{3} \label{eqn:secondequation}
\end{equation}
\end{eq}