目前我正在使用
\newcommand{\newchapter}[1]{\rule{\linewidth}{0.25pt} \vspace*{-0.30cm} \\ \textbf{\textcolor{red}{\Large #1}} \vspace*{-0.15cm}\\\rule{\linewidth}{0.25pt}\par}
使部分像标题一样。但这样做感觉不对,因为 latex 有真实的概念sections
(并且通过使用重新设计的节,内容的可移植性更强(将其复制粘贴到另一个文档))。
参见此处的 MWE:
\documentclass{scrartcl}
\usepackage{fontspec} % LuaLaTeX
\usepackage{multicol} % use \begin{multicols}{num} text \end{multicols} and the text will be automatically distributed
\usepackage{scrlayer-scrpage} % header and footer
\usepackage{xcolor}
% ----- Settings -----
\KOMAoptions{
paper=a4, % set papersize
paper=landscape, % set paperformat
fontsize=6.6pt, % set fontsize
parskip=half, % half a line will seperate paragraphs
headings=normal, % headings in normalsize
twoside=false, % onesided document
twocolumn=false, % one columned pages
numbers=autoendperiod, % automatic punctuation in outline
}
% turn off header and footer
\pagestyle{empty}
\areaset{835pt}{585pt}
% indentation
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt plus 0.5ex}
% big red titles for chapters
\newcommand{\newchapter}[1]{\rule{\linewidth}{0.25pt} \vspace*{-0.30cm} \\ \textbf{\textcolor{red}{\Large #1}} \vspace*{-0.15cm}\\\rule{\linewidth}{0.25pt}\par}
% blue titles for single topics within a chapter
\newcommand{\topic}[1]{\textbf{\textcolor{blue}{#1}}}
% green and bold text for important concepts
\newcommand{\term}[2][]{%
\if n#1\else\hangindent=1em\hangafter=1\fi%
\textbf{\textcolor{green!50!black}{#2}}%
}
\renewcommand{\baselinestretch}{1.3}
\setlength{\columnseprule}{.01pt}
\begin{document}
\begin{multicols}{3}
\newchapter{NewChapter}
\topic{Topic}
\term{Term}
\newpage
force pagebreak
\end{multicols}
\end{document}
(不要对奇怪的字体大小/纸张大小感到疑惑,它应该这样才能尽可能地适应页面)
因此我想使用section
Instead of newchapter
、subsection
Instead oftopic
和paragraph
Instead of term
。
有没有办法做到这一点(如果有,该怎么做)?请注意topic
and后面缺少的换行符term
(但如果无法避免这些换行符,我会没事的)
抱歉,这是一个非常明显的问题,但我已经研究过\RedeclareSectionCommand
并且\setkomafont
(适用于颜色,但我不确定hangindent
(术语)和\rule
(新章节),特别是\rule
章节文本之后)。
注意:我正在使用进行编译lualatex
,但这不应该产生相关的效果。
赏金注意事项:
newChapter
和topic
都已解决 (请参阅esdd
答案),但我仍然在为 而苦苦挣扎hangindent
。\term
我知道我可以做到\newcommand{\term}[1]{\paragraph{#1}\hangindent=1em\hangafter=1}
,但我仍然想\paragraph
在文档主体中使用,以便轻松更改格式。
答案1
section
以下是针对和标题的建议subsection
:
\documentclass{scrartcl}
\usepackage{fontspec}
\usepackage{multicol}
%\usepackage{scrlayer-scrpage}% <- not used in the example
\usepackage{xcolor}
\usepackage{blindtext}% only for dummy text
% ----- Settings -----
\KOMAoptions{
%paper=a4,% default
paper=landscape,
fontsize=6.6pt,
%parskip=half,% <- overwritten by \setparsizes
headings=normal,
%twoside=false,% default with scrartcl
%twocolumn=false,% default
%numbers=autoendperiod,% default
}
\pagestyle{empty}
\areaset{835pt}{585pt}
\setparsizes{0pt}{0pt}{1em plus 1fil}% indentation
\setcounter{secnumdepth}{\partnumdepth}% unnumbered sections etc.
% big red titles for sections
\RedeclareSectionCommand[
beforeskip=0pt,
afterskip=0pt,
afterindent=false,
runin=false,
font=\rmfamily\color{red}\Large
]{section}
\newcommand*{\originalsectionlinesformat}{}
\let\originalsectionlinesformat\sectionlinesformat
\renewcommand*{\sectionlinesformat}[4]{%
\Ifstr{#1}{section}
{\setlength\parfillskip{0pt}\textcolor{black}{\rule{\linewidth}{0.25pt}}\nopagebreak\par\vskip-.1cm#4\nopagebreak\par\vskip-.3cm \textcolor{black}{\rule{\linewidth}{0.25pt}}}
{\originalsectionlinesformat{#1}{#2}{#3}{#4}}%
}
% blue titles for subsections:
\RedeclareSectionCommand[
runin=true,
beforeskip=0pt,
afterskip=1ex,
font=\rmfamily\color{blue}
]{subsection}
% green and bold text for important concepts:
\newcommand{\term}[2][]{%
\if n#1\else\hangindent=1em\hangafter=1\fi%
\textbf{\textcolor{green!50!black}{#2}}%
}
\renewcommand{\baselinestretch}{1.3}
\setlength{\columnseprule}{.01pt}
\begin{document}
\begin{multicols}{3}
\section{NewSection}
\subsection{Topic}
\term{Term}
\newpage
force pagebreak
\end{multicols}
\end{document}