为新部分创建样式

为新部分创建样式

有人能帮我做这样的事吗?
作为我文档中的信息部分 在此处输入图片描述

答案1

以下是使用多功能tcolorbox包;根据需要调整设置:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}% just to generate text for the example

\definecolor{color1}{RGB}{249,179,72}
\definecolor{color2}{RGB}{0,112,131}

\newtcolorbox{historical}{
sidebyside,
sidebyside align=top,
lefthand width=3cm,
sidebyside gap=14pt,
freelance,
interior code={},
frame code={},
overlay={
  \shade[top color=color2,bottom color=color2!10]
  ([xshift=6pt,yshift=8pt]frame.north west) 
    rectangle
  ([xshift=11pt,yshift=-6pt]frame.south west);
  \draw[color=color2,line width=1.5pt]
  ([yshift=4pt]title.north west) --
  ([yshift=4pt]title.north east);
  \draw[color=color2,line width=1.5pt]
  ([yshift=-2pt]frame.south west) --
  ([yshift=-2pt]frame.south east);
  },
colback=white,  
title=Historical,
center title,
title code={
  \fill[left color=color1,right color=color1!10]
  (title.north west)
    rectangle
  (title.south east);
  },
segmentation code={},
fonttitle=\large\sffamily\bfseries,
coltitle=black,
enlarge left by=-16pt,
enlarge right by=-16pt,
width=\textwidth+32pt,
left=15pt,
right=15pt,
before=\par\bigskip\noindent,  
after=\par\medskip
}

\newcommand\Name[1]{%
  \textcolor{color2}{\sffamily\bfseries #1}%
}
\newcommand\PersonInfo[1]{%
  {\par\smallskip\noindent\footnotesize\raggedright #1\par}%
}

\begin{document}

\lipsum[4]
\begin{historical}
\includegraphics[height=4.5cm,width=3cm]{example-image-a}
\PersonInfo{Some text here describing the source of the image}
\tcblower
\Name{Alessandro Antonio Volta}
\lipsum[4]
\end{historical}
\lipsum[4]

\end{document}

在此处输入图片描述

历史信息只是通过historical环境和一些辅助命令提供:

\begin{historical}
\includegraphics[height=4.5cm,width=3cm]{example-image-a}
\PersonInfo{Some text here describing the source of the image}
\tcblower
\Name{Alessandro Antonio Volta}
text describing the person.
\end{historical}

还有另一种选择,使用同样多功能的mdframed这次:

\documentclass{article}
\usepackage{graphicx}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}% just to generate text for the example
\usetikzlibrary{calc}

\definecolor{color1}{RGB}{249,179,72}
\definecolor{color2}{RGB}{0,112,131}

\newmdenv[
hidealllines=true,
leftmargin=-16pt,
rightmargin=-16pt,
innerleftmargin=16pt,
innerrightmargin=16pt,
skipabove=35pt,
singleextra={
  \fill[overlay,left color=color1,right color=color1!10]
  ([yshift=4pt]O|-P)
    rectangle
  ([yshift=22pt]P);
  \node[overlay,font=\large\bfseries\sffamily] 
    at ([yshift=13pt] $ (O|-P)!0.5!(P) $ )
    {Historical};
  \shade[overlay,top color=color2,bottom color=color2!10]
  ([xshift=6pt,yshift=30pt]O|-P) 
    rectangle
  ([xshift=11pt,yshift=-8pt]O);
  \draw[overlay,color=color2,line width=1.5pt]
  ([yshift=25.5pt]O|-P) --
  ([yshift=25.5pt]P);
  \draw[overlay,color=color2,line width=1.5pt]
  ([yshift=-2pt]O) --
  ([yshift=-2pt]P|-O);
  },
]{historical}

\newcommand\Name[1]{%
  \textcolor{color2}{\sffamily\bfseries #1}%
}
\newcommand\PersonInfo[1]{%
  {\par\smallskip\noindent\footnotesize\raggedright #1\par}%
}

\begin{document}

\lipsum[4]
\begin{historical}
\begin{minipage}[t]{3cm}
\raisebox{-\dimexpr\totalheight-5pt\relax}{\includegraphics[height=4.5cm,width=3cm]{example-image-a}}
\PersonInfo{Some text here describing the source of the image}
\end{minipage}\hspace{15pt}%
\begin{minipage}[t]{\dimexpr\linewidth-3cm-15pt\relax}
\Name{Alessandro Antonio Volta}
\lipsum[4]
\end{minipage}
\end{historical}
\lipsum[4]

\end{document}

在此处输入图片描述

相关内容