Typora drake-dark.css 主题优化

本文介绍了如何在Markdown中自定义导航栏,使其浮动在右侧,同时为标题添加了特定颜色和序号标识。通过CSS代码实现,适合提升文章结构清晰度。
  • 导航栏:悬浮于右侧
  • 标题:添加颜色、序号

效果图

在这里插入图片描述

添加 css 内容

drake-dark.css 最后添加以下内容

/**
 * 自定义拓展:导航栏右悬浮、标题颜色、标题序号
 */

.md-toc {
    float: right;
    z-index: 1000;
    position: fixed;
    top: 17.6%;
    right: 45px;
}

#write {
    counter-reset: h1;
	cursor: text;
	transform: inherit;
}

h1 {
    counter-reset: h2;
	color: #f9963b;
    font-size: 2rem;
    margin-top: 0px;
    padding-top: 24px;
    text-align: left;
}

h2 {
    counter-reset: h3;
	color: #46ACC8;
    font-size: 1.4rem;
}

h2 .md-plain {
    padding-bottom: 0px;
    border-bottom: 0;
    line-height: 0px;
}

h3 {
    counter-reset: h4;
    color: #9ABC77;
    font-size: 1.2rem;
}

h4 {
    font-size: 1.2rem;
}

h5 {
    font-size: 1.2rem;
}

h6 {
    font-size: 1.2rem;
}

#write h1:before {
    counter-increment: h1;
    content: counter(h1) ". "
}

#write h2:before {
    counter-increment: h2;
    content: counter(h1) "." counter(h2) " "
}

#write h3:before, h3.md-focus.md-heading:before {
    counter-increment: h3;
    content: counter(h1) "." counter(h2) "." counter(h3) " "
}

#write h4:before, h4.md-focus.md-heading:before {
    counter-increment: h4;
    content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) " "
}

#write h5:before, h5.md-focus.md-heading:before {
    counter-increment: h5;
    content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) " "
}

#write h6:before, h6.md-focus.md-heading:before {
    counter-increment: h6;
    content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) " "
}

#write > h3.md-focus:before,
#write > h4.md-focus:before,
#write > h5.md-focus:before,
#write > h6.md-focus:before,
h3.md-focus:before,
h4.md-focus:before,
h5.md-focus:before,
h6.md-focus:before {
    color: inherit;
    border: inherit;
    border-radius: inherit;
    position: inherit;
    left: inherit;
    float: inherit;
    top: inherit;
    font-size: inherit;
    padding-left: inherit;
    padding-right: inherit;
    vertical-align: inherit;
    font-weight: inherit;
    line-height: inherit;
    visibility: inherit;
}
### 使用 `drake-config.cmake` 集成 Drake 到 CMake 项目的配置方法 为了在 CMake 项目中集成 Drake 并利用其提供的 `drake-config.cmake` 文件,可以按照以下方式操作: #### 1. 安装或获取 Drake 库 确保已经安装了 Drake 库并将其放置在一个可访问的位置。如果通过源码编译,则需要完成构建过程[^1]。 ```bash cd drake-distro mkdir build cd build cmake .. make ``` Drake 提供了一个预构建的包管理器支持(如 vcpkg),或者可以通过官方文档中的说明下载已发布的二进制版本。 --- #### 2. 查找 `drake-config.cmake` 通常情况下,`drake-config.cmake` 文件会被安装到系统的标准路径下,例如 `/usr/local/lib/cmake/drake/` 或者 `$DRAKE_INSTALL_DIR/lib/cmake/drake/` 中。如果没有找到该文件,可能是因为未正确安装 Drake 或者环境变量未设置。 验证 Drake 是否被成功安装以及查找 `drake-config.cmake` 的位置: ```bash find /path/to/drake/install -name "drake-config.cmake" ``` 如果找不到此文件,建议重新执行 Drake 构建流程,并确认是否启用了 CMake 导出功能。 --- #### 3. 修改当前项目的 CMakeLists.txt 为了让您的项目能够识别 Drake 的依赖项,在项目的根目录下的 `CMakeLists.txt` 文件中添加以下内容: ```cmake # 设置最低版本要求 cmake_minimum_required(VERSION 3.10) # 定义项目名称 project(MyProject LANGUAGES CXX) # 添加 Drake 路径 (如果有自定义安装路径) set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/path/to/drake/install") # 查找 Drake 包 find_package(drake REQUIRED) # 如果找到了 Drake, 输出一些调试信息 if(DRKE_FOUND) message(STATUS "Found Drake: ${drake_VERSION}") endif() # 将目标链接到 Drake add_executable(my_application main.cpp) target_link_libraries(my_application PRIVATE drake::drake) ``` 上述脚本的关键部分在于调用 `find_package(drake REQUIRED)` 来加载 `drake-config.cmake` 文件,并自动导入所需的库和头文件路径[^3]。 --- #### 4. 处理潜在错误 如果您遇到与 Xcode 开发者工具相关的错误,可能是由于缺少必要的开发组件引起的。解决办法是运行以下命令来更新开发者工具链[^4]: ```bash xcode-select --install ``` 这一步骤对于 macOS 用户尤为重要,因为它会修复因缺失基础工具而导致的 CMake 错误。 --- #### 5. 测试集成效果 创建一个简单的测试程序以验证 Drake 的集成情况。假设您有一个名为 `main.cpp` 的文件,内容如下所示: ```cpp #include <iostream> #include "drake/systems/framework/context.h" int main() { using namespace drake; systems::Context<double> context(nullptr); std::cout << "Drake Context Initialized!" << std::endl; return 0; } ``` 随后运行以下命令进行构建和测试: ```bash mkdir build && cd build cmake .. make ./my_application ``` 如果一切正常,应该可以看到输出消息:“Drake Context Initialized!”。 --- ### 注意事项 - 确保 `drake-config.cmake` 存在于指定路径中;否则,CMake 可能无法解析 Drake 的模块。 - 若使用的是特定版本控制分支,请注意不同版本间的 API 差异可能会引起兼容性问题。 ---
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值