围绕部分 \section 画一个圆圈

围绕部分 \section 画一个圆圈

我想要画一个圆圈,\section像下面这张图片一样。

在此处输入图片描述

\documentclass[a4paper]{article}

\usepackage{fullpage} % Package to use full page


\title{Understanding Poisson Processes}
\author{Author}

\begin{document}

\maketitle
\section{Introduction}
Differentiation is a concept of Mathematics studied in Calculus. There is an ongoing discussion as to who was the first to define differentiation: Leibniz or Newton.
Differentiation allows for the calculation of the slope of the tangent of a curve at any given point as shown in Figure 1.
\end{document}

答案1

当有十个或更多部分时,圈出部分的数字会出现一个无法解决的问题:或者圆圈的大小会发生变化,如果你同时看到一个和两个数字的部分,则不太美观(如 Christian 的回答中所述)或者你对所有部分使用固定大小的大圆圈(尽管当它应该足够大以容纳三位数时,这种方法是否优雅值得怀疑,如本回答中所述)。如果必须选择,我会选择第二种,因为我很少需要编写包含大量部分的文档。否则,我会选择椭圆形框而不是圆圈,以避免大圆圈过高。

为了将此评论转化为真正的答案,这里有一个解决方案,没有可预测的tikz方法,但 titlesec(为了避免\directly@touch\the@latex\@guts)以及经典的picture圆形椭圆框。还添加了一个更简单的解决方案fancybox(尽管它们的圆角能力有限)。

姆韦

\documentclass{article}
\usepackage{titlesec}
\usepackage{fancybox}
\def\a{Lore ipsum dolor sit amet\ldots}
\begin{document}

\setcounter{section}{4}\section{Introduction}\a  
\setcounter{section}{78}\section{Introduction}\a
\setcounter{section}{168}\section{Introduction}\a 

\titleformat{\section}{\Large\bfseries}{}{0em}{%
\begin{picture}(0,0)
\put(12,4){\circle{28}}
\end{picture}\makebox[1.45em][c]{\thesection}\quad}

\setcounter{section}{4}\section{Introduction}\a  
\setcounter{section}{78}\section{Introduction}\a
\setcounter{section}{168}\section{Introduction}\a 

\titleformat{\section}{\Large\bfseries}{}{0em}{%
\begin{picture}(0,0)
\put(12,4){\oval(28,22)}
\end{picture}\makebox[1.45em][c]{\thesection}\quad}

\setcounter{section}{4}\section{Introduction}\a  
\setcounter{section}{78}\section{Introduction}\a
\setcounter{section}{168}\section{Introduction}\a 


\titleformat{\section}{\Large\bfseries}{}{0em}%
{\fboxsep1ex\cornersize{.7}\ovalbox{\thesection}\quad}

\setcounter{section}{4}\section{Introduction}\a  
\setcounter{section}{78}\section{Introduction}\a
\setcounter{section}{168}\section{Introduction}\a 

\end{document}

答案2

通过 hacking,\@svsec可以插入TikZ用圆圈绘制的节点。由于只有部分编号应该用圆圈标记,因此进行了测试\pdfstrcmp(仅适用于pdflatex),然后\circlednumber调用,应用TikZ此处的代码。

请注意,目录中的数字并没有以这种方式圈出来。

\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage{xpatch}
\usepackage{fullpage} % Package to use full page

\newcommand{\circlednumber}[1]{%
  \begin{tikzpicture}[baseline=(A.base)]%
    \node[circle,draw,inner sep=1pt,outer sep=1pt] (A) {#1};
  \end{tikzpicture}%
}

\title{Understanding Poisson Processes}
\author{Author}

\makeatletter
\xpatchcmd{\@sect}{%
  \protected@edef\@svsec{\@seccntformat{#1}\relax}%
}{%
  \ifnum0=\pdfstrcmp{#1}{section}%
  \def\@svsec{\circlednumber{\number\value{section}}\quad\relax}%
  \else
  \protected@edef\@svsec{\@seccntformat{#1}\relax}%
  \fi
  }{}{}
\makeatother

\begin{document}

\maketitle
\section{Introduction}
Differentiation is a concept of Mathematics studied in Calculus. There is an ongoing discussion as to who was the first to define differentiation: Leibniz or Newton.
Differentiation allows for the calculation of the slope of the tangent of a curve at any given point as shown in Figure 1.
\subsection{Foo}

\setcounter{section}{9}
\section{Outroduction}
\end{document}

在此处输入图片描述

答案3

使用 \textcircled(无需 tikz)可以更轻松地围绕某个部分绘制圆圈:

    \documentclass[a4paper]{article}

    \usepackage{enumitem}     % for textcircled
    \usepackage{titlesec}
    \renewcommand{\thesection}{\arabic{section}}

    \begin{document}

    \titleformat{\section}{\Large\bfseries}{\textcircled{\large{\thesection}}}{0.5em}{}

    \section{Introduction}
     Text for introduction

    \section{Annexe}
    Text for Annexe
    \end{document}

在此处输入图片描述

如果你想要的东西不那么“圆形”或者更“椭圆形”,你可以使用 ovalbox:

    \documentclass{article}

    \usepackage{fancybox}     
    \usepackage{titlesec}
    \renewcommand{\thesection}{\arabic{section}}


    \begin{document}

    \cornersize{0.6}    %cornersize{1} =circle and cornersize{0} = rectangle
    \titleformat{\section}{\Large\bfseries}{\ovalbox{\thesection}}{0.5em}{}

    \section{Introduction}
    Text for introduction

    \section{Annexe}
    Text for annexe
    \end{document}

在此处输入图片描述

答案4

另外两种可能性,与titlesecpstricks

\documentclass[a4paper]{article}

\usepackage{fullpage} % Package to use full page
\usepackage{titlesec}
\usepackage{pstricks}
\usepackage{auto-pst-pdf} %% to compile with pdflatex

\title{Understanding Poisson Processes}
\author{Author}

\begin{document}

\maketitle

\titleformat{\section}[hang]{\Large\bfseries}{\raisebox{-0.29\height}{\pscirclebox{\thesection}}}{0.6em}{}
\section{Introduction}
Differentiation is a concept of Mathematics studied in Calculus. There is an ongoing discussion as to who was the first to define differentiation: Leibniz or Newton.
Differentiation allows for the calculation of the slope of the tangent of a curve at any given point as shown in Figure 1.


\titleformat{\section}[hang]{\Large\bfseries}{\makebox[0pt]{\raisebox{-0.32\height}{\pscirclebox[shadow=true, shadowsize=2pt]{\thesection}}}}{1.2em}{}
\section{Another Introduction}
Differentiation is a concept of Mathematics studied in Calculus. There is an ongoing discussion as to who was the first to define differentiation: Leibniz or Newton.
Differentiation allows for the calculation of the slope of the tangent of a curve at any given point as shown in Figure 1.


\end{document} 

在此处输入图片描述

相关内容