使用 Tikz 和 Titlesec 制作精美标题

使用 Tikz 和 Titlesec 制作精美标题

我想用两条蓝色垂直线连接蓝色平行线。有没有简单的方法可以解决这个问题?谢谢在此处输入图片描述

\documentclass[oneside]{article}
\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.6 in}
\setlength{\textwidth}{6.5 in}
\setlength{\textheight}{8.5 in}
\setlength{\headsep}{0.75 in}
\setlength{\parindent}{0 in}
\setlength{\parskip}{0.1 in}

\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{titlesec}
\usepackage{enumitem}

\newcommand\titlebar{%
\tikz[baseline,trim left=3.1cm,trim right=3cm] {
     \draw [thick,blue] (2.5cm,3ex)--(\textwidth+3.1cm,3ex);
    %\fill [cyan!25] (2.5cm,-1ex) rectangle (\textwidth+3.1cm,2.5ex);
    \node [draw=blue,thick,
         %fill=cyan!20!white,
                shade, shading=axis, left color=blue!50!white, right color=green,
    shading angle=45, 
    anchor=base east,
    rectangle,minimum width=2.5cm,
    minimum height=4.5ex] at (3cm,0) {\color{white}{}
    \textbf{R.\thesection}%\textbf{\arabic{chapnum}.\thesection}
    };
  }%
}

 \titleformat{\section}{\bf \LARGE}{\titlebar}{0.1cm}{\color{blue}}

 \renewcommand*{\thesection}{\arabic{section}}

 \begin{document}

 \section{Graphs and Equations    }
 \begin{enumerate}
 \item[\color{Aquamarine}{$\bullet$}] Graph equations
 \item[\color{Aquamarine}{$\bullet$}] Use graphs as mathematical models to 
 make predictions.
 \item[\color{Aquamarine}{$\bullet$}] Carry out calculations involving 
 compound interest.
\end{enumerate}

\tikz[trim left=3.1cm,trim right=3cm] {
       \draw [thick,blue] (3cm,3ex)--(\textwidth+3.1cm,3ex);
         }

 \color{red}{{\bf \Large What is Calculus?}}        

 \end{document}

答案1

你当然可以这样做,但是你确定要这样做吗?

\documentclass[oneside]{article}
\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.6 in}
\setlength{\textwidth}{6.5 in}
\setlength{\textheight}{8.5 in}
\setlength{\headsep}{0.75 in}
\setlength{\parindent}{0 in}
\setlength{\parskip}{0.1 in}

\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{titlesec}
\usepackage{enumitem}

\newcommand\titlebar{%
\tikz[baseline,trim left=3.1cm,trim right=3cm,remember picture] {
     \draw [thick,blue] (2.5cm,3ex)
     coordinate (TB\thesection-tl)--(\textwidth+3.1cm,3ex)
     coordinate (TB\thesection-tr);
    %\fill [cyan!25] (2.5cm,-1ex) rectangle (\textwidth+3.1cm,2.5ex);
    \node [draw=blue,thick,
         %fill=cyan!20!white,
                shade, shading=axis, left color=blue!50!white, right color=green,
    shading angle=45, 
    anchor=base east,
    rectangle,minimum width=2.5cm,
    minimum height=4.5ex] at (3cm,0) {\color{white}{}
    \textbf{R.\thesection}%\textbf{\arabic{chapnum}.\thesection}
    };
  }%
}

 \titleformat{\section}{\bf \LARGE}{\titlebar}{0.1cm}{\color{blue}}

 \renewcommand*{\thesection}{\arabic{section}}

 \begin{document}

 \section{Graphs and Equations    }
 \begin{enumerate}
 \item[\color{Aquamarine}{$\bullet$}] Graph equations
 \item[\color{Aquamarine}{$\bullet$}] Use graphs as mathematical models to 
 make predictions.
 \item[\color{Aquamarine}{$\bullet$}] Carry out calculations involving 
 compound interest.
\end{enumerate}

\tikz[trim left=3.1cm,trim right=3cm,remember picture] {
       \draw [thick,blue] (3cm,3ex) coordinate (auxL)
       --(\textwidth+3.1cm,3ex) coordinate (auxR);
         }
\tikz[overlay,remember picture]{
\draw[thick,blue] (TB\thesection-tl -| auxL) -- (auxL);
\draw[thick,blue] (TB\thesection-tr) -- (auxR);
}
\textcolor{red}{\Large\textbf{ What is Calculus?}}        

\end{document}

还是我接错了线?

在此处输入图片描述

相关内容