![라벨이 지정된 섹션에 상자 추가](https://rvso.com/image/287000/%EB%9D%BC%EB%B2%A8%EC%9D%B4%20%EC%A7%80%EC%A0%95%EB%90%9C%20%EC%84%B9%EC%85%98%EC%97%90%20%EC%83%81%EC%9E%90%20%EC%B6%94%EA%B0%80.png)
교과서의 반복 섹션에 질문 토론을 제공하는 상자를 추가하고 싶습니다. 프리앰블에 "tex 스타일 설정" 명령을 추가하면 가능합니까? 저는 회고록 수업을 사용하고 있습니다.
(수동으로 작성하는 대신 Scrivener 및 Multimarkdown을 통해 LaTeX 파일의 주요 콘텐츠를 생성하기 때문에 필요합니다.)
나는 tex를 사용했다.여기멋진 섹션 제목을 생성합니다. 내가 하고 싶은 것은 장 끝 부분에 있는 2개의 섹션(요약 및 토론)에 유사한 스타일을 적용하는 것입니다. 그러나 이 섹션은 섹션이 아니기 때문에 섹션 번호가 없는 제목을 원합니다.
이것은 중요한 텍스트입니다.
\newcommand\titlebar{%
\tikz[baseline,trim left=3.1cm,trim right=3cm] {
\fill [black!10] (2.5cm,-1ex) rectangle (\textwidth+3.8cm,2.5ex);
\node [
fill=cyan!60!white,
fill=black!90!white,
anchor= base east,
rounded rectangle,
minimum height=3.75ex] at (2.9cm,0) {
\textbf{\arabic{chapter}.\thesection.}
\color{white}\textbf{T\thesection}
};
}%
}
\titleformat{\section}{\large}{\titlebar}{0.1cm}{}
\renewcommand*{\thesection}{\arabic{section}}
이렇게 하면 섹션 번호를 포함하여 섹션 제목에 멋진 스타일이 적용됩니다. 이제 장 끝에 나타나는 요약과 토론이라는 두 섹션에 비슷한 스타일을 적용하고 싶습니다. 하지만 저는 그 두 섹션에 섹션 번호가 없기를 원합니다.
답변1
다음과 같은 중요한 부분에 대해 새로운 매크로를 정의하는 것이 최선이라고 말하고 싶습니다.
\newcommand{\dsection}[1]{\section*{\titlebar*#1}}
의 단순화된(별표 표시) 버전을 사용합니다 \titlebar
(아래 전체 코드 참조).
\documentclass{memoir}
\usepackage{titlesec,letltxmacro}
\usepackage{lipsum}
\usepackage{tikz}\usetikzlibrary{shapes.misc}
\makeatletter
\newcommand\titlebar@@{%
\tikz[baseline,trim left=3.1cm,trim right=3cm] {
\fill [cyan!25] (2.5cm,-1ex) rectangle (\textwidth+3.1cm,2.5ex);
}}
\newcommand\titlebar@{%
\tikz[baseline,trim left=3.1cm,trim right=3cm] {
\fill [cyan!25] (2.5cm,-1ex) rectangle (\textwidth+3.1cm,2.5ex);
\node [
fill=cyan!60!white,
anchor= base east,
rounded rectangle,
minimum height=3.5ex] at (3cm,0) {
\textbf{\arabic{chapter}.\thesection.}
};
}}
\newcommand\titlebar{\@ifstar\titlebar@@\titlebar@}
\titleformat{\section}{\large}{\titlebar}{0.1cm}{}
\renewcommand*{\thesection}{\arabic{section}}
\LetLtxMacro{\LtxSection}{\section}
\newcommand{\dsection}[1]{\LtxSection*{\titlebar*#1}}
\renewcommand{\section}[2][]{%
\def\secname{#2}
\ifx\somename\secname
\LtxSection*{\titlebar*#2}
\else
\LtxSection[#1]{#2}
\fi}
\def\somename{Summary}
\makeatother
\begin{document}
\chapter{First Chapter}
\section{Section name}
\lipsum[2]
\dsection{Some other Chapter}
\lipsum[2]
\section{Summary}
\lipsum[2]
\end{document}
메모:요청에 따라 \desction
형식은 "요약"이라는 모든 섹션에 자동으로 적용됩니다.
부록
섹션 제목을 굵게 표시하려면 해당 줄을 변경하기만 하면 됩니다.
\titleformat{\section}{\large}{\titlebar}{0.1cm}{}
에게
\titleformat{\section}{\large\bfseries}{\titlebar}{0.1cm}{}