消除 \renewcommand\item 中的缩进

消除 \renewcommand\item 中的缩进

我正在使用一个包含带有\newenvironment和 的宏的类\renewcommand\item。我一直在努力解决缩进问题,在正常情况下\begin{itemize},我找到了消除缩进的简单解决方案,但它们似乎对我的情况不起作用。

重要的是我一直在寻找消除压痕的解决方案本地,因为在我的文档中我还有其他列表想要用标准缩进来保留。

我正在使用的类如下(\newenvironment{educationlist}我想消除缩进):

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tccv}
              [2012/11/09 v1.0
 Two Column Curriculum Vitae]

\LoadClass[10pt]{scrartcl}

\setcounter{secnumdepth}{-1}
\RequirePackage[hmargin=1.25cm,vmargin=1.25cm,twocolumn,columnsep=1.25cm]{geometry}
\RequirePackage{bookman,etoolbox,hyperref,needspace,tabularx,xcolor,fontawesome,makecell,graphicx}

% Capitalize words of at least a minimum length (default to 3 chars).
% The text is capitalized before being expanded.
%
% This macro uses Lua to do the job but fails gracefully (that is,
% return the text as is) if \directlua is not available.
%
% |[
% \ucwords[optional: miminum length]{text}
% ]|
\newcommand\ucwords[2][3]{%
    % Fails gracefully if not in LuaLaTeX
    \providecommand\directlua[1]{#2}%
    \directlua{%
    local minlen=tonumber("#1")
    local src="\luaescapestring{\unexpanded{#2}}"
    local dst={}
    for w in src:gmatch('[^\string\%s]+') do
        if w:len() >= minlen then w = w:sub(1,1):upper()..w:sub(2) end
        table.insert(dst, w)
    end
    tex.print(dst)}}

\pagestyle{empty}
\setlength\parindent{0pt}
\color[HTML]{303030} % Default foreground color
\definecolor{link}{HTML}{506060} % Hyperlinks
\hypersetup{colorlinks,breaklinks,urlcolor=link,linkcolor=link}
\setkomafont{disposition}{\color[HTML]{0058B6}}
\setkomafont{section}{\scshape\Large\mdseries}

% Overrides the \section command to capitalize every
% word for cosmetic purposes and draws a rule under it.
\let\old@section\section
\renewcommand\section[2][]{%
    \old@section[#1]{\ucwords{#2}}%
    \newdimen\raising%
    \raising=\dimexpr-0.7\baselineskip\relax%
    \vskip\raising\hrule height 0.4pt\vskip-\raising}

% Allow conditionals based on the job name. This can usually be set
% from a command-line argument: check fausto.en.tex for an example.
%
% |[
% \ifjob{jobname}{content if matches}{content if does not match}
% ]|
\newcommand\ifjob[3]{%
    \edef\JOBNAME{\jobname}%
    \edef\PIVOT{\detokenize{#1}}%
    \ifdefstrequal{\JOBNAME}{\PIVOT}{#2}{#3}%
}

% Use only \item inside this environment: no other macros
% are allowed:
%
% |[
% \item[optional: what has been achieved]{years}{subject}{notes}
% ]|
\newenvironment{educationlist}{%
    \renewcommand\item[4][]{%
    {\bfseries ##3} & {\raggedleft\scshape ##2} \\
    \ifstrempty{##1}{}{\multicolumn{2}{l}{\begin{minipage}{0.45\textwidth}\scshape ##1\end{minipage}} \smallskip\\}
    \multicolumn{2}{l}{\begin{minipage}{0.45\textwidth}\itshape ##4\end{minipage}}\medskip\\}
    \tabularx{\linewidth}{X r}}
    {\endtabularx}

% Use only \item inside this environment: no other macros
% are allowed:
%
% |[
% \item{fact}{description}
% ]|
\newenvironment{factlist}{%
    \newdimen\unbaseline
    \unbaseline=\dimexpr-\baselinestretch\baselineskip\relax
    \renewcommand\item[2]{%
    \textsc{##1} & {\raggedright ##2\medskip\\}\\[\unbaseline]}
    \tabularx{\linewidth}{rX}}
    {\endtabularx}

Latex 文档:

\documentclass{tccv}
\usepackage[english]{babel}
\usepackage{fontawesome}
\usepackage[gen]{eurosym}

\begin{document}

\section{Education}

\begin{educationlist}

\item[High school diploma]{1988 -- 1992}
     {Informatic engineer}
     {ITIS Castelli, Brescia}

\item{1987 -- 1988}
     {Classical gymnasium}
     {Seminario vescovile, Cremona}

\end{educationlist}

\section{Languages}

\begin{factlist}
\item{Spanish}{Native speaker}
\item{English}{Level C2}
\item{French}{Level C1}
\end{factlist}

\end{document}

结果(如您所见,教育部分有一个缩进,我想消除它,同时保留语言):在此处输入图片描述

提前致谢!

答案1

这是修改后的类,名称为mytccv.cls。缩进来自\tabcolsep的左侧,tabular用于重新定义\item。我还擅自为章节标题下的线条着色(与字体相同):

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tccv}
              [2012/11/09 v1.0
 Two Column Curriculum Vitae]

\LoadClass[10pt]{scrartcl}

\setcounter{secnumdepth}{-1}
\RequirePackage[hmargin=1.25cm,vmargin=1.25cm,twocolumn,columnsep=1.25cm]{geometry}
\RequirePackage{bookman,etoolbox,hyperref,needspace,tabularx,xcolor,fontawesome,makecell,graphicx}

% Capitalize words of at least a minimum length (default to 3 chars).
% The text is capitalized before being expanded.
%
% This macro uses Lua to do the job but fails gracefully (that is,
% return the text as is) if \directlua is not available.
%
% |[
% \ucwords[optional: miminum length]{text}
% ]|
\newcommand\ucwords[2][3]{%
    % Fails gracefully if not in LuaLaTeX
    \providecommand\directlua[1]{#2}%
    \directlua{%
    local minlen=tonumber("#1")
    local src="\luaescapestring{\unexpanded{#2}}"
    local dst={}
    for w in src:gmatch('[^\string\%s]+') do
        if w:len() >= minlen then w = w:sub(1,1):upper()..w:sub(2) end
        table.insert(dst, w)
    end
    tex.print(dst)}}

\pagestyle{empty}
\setlength\parindent{0pt}
\color[HTML]{303030} % Default foreground color
\definecolor{link}{HTML}{506060} % Hyperlinks
\hypersetup{colorlinks,breaklinks,urlcolor=link,linkcolor=link}
\setkomafont{disposition}{\color[HTML]{0058B6}}
\setkomafont{section}{\scshape\Large\mdseries}

% Overrides the \section command to capitalize every
% word for cosmetic purposes and draws a rule under it.
\let\old@section\section
\renewcommand\section[2][]{%
    \old@section[#1]{\ucwords{#2}}%
    \newdimen\raising%
    \raising=\dimexpr-0.7\baselineskip\relax%
    \vskip\raising{\color[HTML]{0058B6} \hrule height 0.4pt}\vskip-\raising}


% Allow conditionals based on the job name. This can usually be set
% from a command-line argument: check fausto.en.tex for an example.
%
% |[
% \ifjob{jobname}{content if matches}{content if does not match}
% ]|
\newcommand\ifjob[3]{%
    \edef\JOBNAME{\jobname}%
    \edef\PIVOT{\detokenize{#1}}%
    \ifdefstrequal{\JOBNAME}{\PIVOT}{#2}{#3}%
}

% Use only \item inside this environment: no other macros
% are allowed:
%
% |[
% \item[optional: what has been achieved]{years}{subject}{notes}
% ]|
\newenvironment{educationlist}{%
    \renewcommand\item[4][]{%
    {\bfseries ##3} & {\raggedleft\scshape ##2} \\
    \ifstrempty{##1}{}{\multicolumn{2}{@{}l}{\begin{minipage}{0.45\textwidth}\scshape ##1\end{minipage}} \smallskip\\}
    \multicolumn{2}{@{}l}{\begin{minipage}{0.45\textwidth}\itshape ##4\end{minipage}}\medskip\\}
    \tabularx{\linewidth}{@{}X r}}
    {\endtabularx}

% Use only \item inside this environment: no other macros
% are allowed:
%
% |[
% \item{fact}{description}
% ]|
\newenvironment{factlist}{%
    \newdimen\unbaseline
    \unbaseline=\dimexpr-\baselinestretch\baselineskip\relax
    \renewcommand\item[2]{%
    \textsc{##1} & {\raggedright ##2\medskip\\}\\[\unbaseline]}
    \tabularx{\linewidth}{@{}rX}}
    {\endtabularx}

以及 LaTeX 代码:

\documentclass{mytccv}
\usepackage[english]{babel}
\usepackage{fontawesome}
\usepackage[gen]{eurosym}

\begin{document}

\section{Education}

\begin{educationlist}

\item[High school diploma]{1988 -- 1992}
     {Informatic engineer}
     {ITIS Castelli, Brescia}

\item{1987 -- 1988}
     {Classical gymnasium}
     {Seminario vescovile, Cremona}

\end{educationlist}

\section{Languages}

\begin{factlist}
\item{Spanish}{Native speaker}
\item{English}{Level C2}
\item{French}{Level C1}
\end{factlist}

\end{document} 

在此处输入图片描述

答案2

您必须删除初始(和最终)填充:

\newenvironment{educationlist}{%
    \renewcommand\item[4][]{%
    {\bfseries ##3} & {\raggedleft\scshape ##2} \\
    \ifstrempty{##1}{}{\multicolumn{2}{l}{\begin{minipage}{0.45\textwidth}\scshape ##1\end{minipage}} \smallskip\\}
    \multicolumn{2}{@{}l@{}}{\begin{minipage}{0.45\textwidth}\itshape ##4\end{minipage}}\medskip\\}
    \tabularx{\linewidth}{@{}X r@{}}}
    {\endtabularx}

注意\multicolumn{2}{@{}l@{}}\tabularx{\linewidth}{@{}Xr@{}}

您还应该移出\newdimen\raising重新定义\section

% Overrides the \section command to capitalize every
% word for cosmetic purposes and draws a rule under it.
\let\old@section\section
\newdimen\raising
\renewcommand\section[2][]{%
    \old@section[#1]{\ucwords{#2}}%
    \raising=\dimexpr-0.7\baselineskip\relax
    \vskip\raising\hrule height 0.4pt\vskip-\raising}

但也许没有它会更容易:

% Overrides the \section command to capitalize every
% word for cosmetic purposes and draws a rule under it.
\let\old@section\section
\renewcommand\section[2][]{%
    \old@section[#1]{\ucwords{#2}}%
    \vskip-\ht\strutbox\hrule height 0.4pt}

相关内容