部分格式和样式

部分格式和样式

当我为学生编写教程时,我总是使用班级预定义的部分样式,使其简洁明了article。我查看了一些其他帖子,发现下面的代码将部分的字体样式更改为小写字母。

 \documentclass[letterpaper]{article}
 \usepackage{lipsum}
 \makeatletter
 \renewcommand{\section}{\@startsection {section}{1}{0pt}%
 {-3.5ex plus -1ex minus -.2ex}%
 {2.3ex plus .2ex}%
 {\normalfont\Large\scshape}}
 \makeatother
 \begin{document}
 \section{test}
 \lipsum[1-3]
 \end{document}

但后来我在一些教科书中看到我的学生使用了以下图像: 在此处输入图片描述

我想知道您是否可以帮助我了解编辑部分样式的过程。

答案1

这是使用 mdframed 的另一种方法。

\documentclass{article}
\usepackage{showframe}
\usepackage{enumitem}
\usepackage[framemethod=default]{mdframed}
\usepackage{tikz}
\mdfdefinestyle{conclusion}{%
innerleftmargin=0.3\linewidth,
innerrightmargin=1cm,
leftline=false,
rightline=false,
backgroundcolor=yellow!20,
linecolor=blue,
linewidth=4pt,
skipabove=\dimexpr\topskip+.5cm\relax,
settings={\setlist[itemize]{label=\color{red!60!black}\rule[.25ex]{1ex}{1ex}}%
               \refstepcounter{section}},
frametitleaboveskip=\dimexpr-1.5\ht\strutbox\relax,
frametitle=%
 {%
  \null\llap{%
     \tikz[baseline=(current bounding box.east),outer sep=0pt,remember picture]
      \node[anchor=west,
             xshift=0cm,rectangle,fill=red!60!black,
             rounded corners,
             font=\color{white}\Large\sffamily] (frametitle)%
                                                                 {section~\thesection};
               }%
  }
}

\newmdenv[style=conclusion]{conclusion}

\begin{document}
Text Text
\begin{conclusion}
\begin{itemize}
\item Evaluate a logarithm using the change-of-base formula.
\item Use properties of logarithms to evaluate or rewrite a logarithmic expression
\item \ldots
\end{itemize}
\end{conclusion}
\end{document}

在此处输入图片描述

答案2

这并不假装符合任何印刷指南,但它展示了如何开始,基本上使用\part而不是的定义\section作为基础,如果您想使用额外的样式。它需要 *-ed 形式定义的版本。另外,我color在这里只使用了基本包(因为我对此有所了解),可以使用colorx或获得更多奇特的效果tikz,并且minitoc有很多选项,但我都没有使用过……

在此处输入图片描述

\documentclass{report}
%% minitoc handless per-section tables of contents 
%% color handles colour
\usepackage{minitoc,color}

%% use @ in command names (not needed in a package file)
\makeatletter


%% almost exactly how article.sty defines \part
\def\section{%
   \if@noskipsec \leavevmode \fi
   \par
   \addvspace{4ex}%
   \@afterindentfalse
   \secdef\@mysec\@smysec}


%% The normal form \@smysec would need to be defined
%%  to do the * form so no number ie no
%%  \refstepcounter and possibly no red box
%% [#1] is the optional short form #2 is the main title   
\def\@mysec[#1]#2{%
%% bump the counter
      \refstepcounter{section}%
%% add to the toc
      \addcontentsline{toc}{section}{\thepart\hspace{1em}#1}%
%% some vertical space 
      \bigskip
%% make sure the whole construct stays together not split over a page
      \vbox{%
%% a blue line
      \noindent\textcolor{blue}{\vrule \@height 3pt \@width\linewidth}%
%% back up
      \hspace{-0.75\linewidth}%
%% a red box with some white text
      \colorbox{red}{\color{white}{\normalfont\bfseries\large Section \thesection}}%
      \par
%% this was left in by mistake, but I'll leave it in as that's what
%% made the image
      \vskip -3pt
%% two side by side boxes one for the title and one for minitoc
       \noindent
%% #2 is the title
       \begin{minipage}[t]{0.3\linewidth}\raggedright\large\color{blue}
          \bigskip#2\end{minipage}%
%%  \minitoc makes this sections toc (minitoc package)
       \begin{minipage}[t]{0.7\linewidth}\small\minitoc\end{minipage}%
}%
%%    finish up, again same as \part in article.sty
%%    \@afterheading gets latex to try to keep the next text
%% on same page and by default supresses indentation of the first para
    \nobreak
    \vskip 3ex
    \@afterheading}




\begin{document}
\dominitoc
\tableofcontents


\chapter{hmmmm}

\section{Properties of Logarithms}

blah blah

\subsection{Evaluate a logarithm using\ldots}
blah blah
\subsection{Use properties of logarithms \ldots\ evaluate}
blah blah
\subsection{Use properties of logarithms\ldots\ expand}
blah blah
\subsection{Use logarithmic functions\ldots}
blah blah

\end{document}

答案3

形状、颜色和定位 - 我会使用 TikZ。一种可能的方法:

  • 使用节点作为节号和节标题
  • 为每个元素定义样式,例如那些节点和子部分的项目符号,例如

    \tikzset{section/.style={rectangle, rounded corners,fill=red, inner sep=4pt}}
    
  • 使用baseline选项将节点内容和周围文本对齐到基线

  • 参考current page节点从左到右绘制线条
  • 使用节计数器命名节节点,例如

    \tikz[baseline=(\thesection.base)] \node (\thesection) [section]{#1};}
    
  • 使用minitoc并与 TikZ 样式结合

相关内容